@nutui/nutui-react-taro 1.5.2 → 1.5.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/CHANGELOG.md +0 -1
  2. package/dist/esm/ActionSheet.js +14 -90
  3. package/dist/esm/Address.js +21 -620
  4. package/dist/esm/Animate.js +7 -53
  5. package/dist/esm/AnimatingNumbers.js +7 -125
  6. package/dist/esm/Audio.js +19 -264
  7. package/dist/esm/Avatar.js +11 -130
  8. package/dist/esm/{AvatarContext-15733596.js → AvatarContext-c96afdcc.js} +3 -1
  9. package/dist/esm/AvatarGroup.js +11 -41
  10. package/dist/esm/BackTop.js +10 -138
  11. package/dist/esm/Badge.js +9 -71
  12. package/dist/esm/Barrage.js +8 -97
  13. package/dist/esm/Button.js +9 -108
  14. package/dist/esm/Calendar.js +20 -128
  15. package/dist/esm/CalendarItem.js +12 -674
  16. package/dist/esm/Card.js +11 -61
  17. package/dist/esm/Cascader.js +16 -671
  18. package/dist/esm/Cell.js +9 -101
  19. package/dist/esm/CellGroup.js +5 -2
  20. package/dist/esm/Checkbox.js +7 -5
  21. package/dist/esm/CheckboxGroup.js +8 -111
  22. package/dist/esm/CircleProgress.js +8 -114
  23. package/dist/esm/Col.js +7 -57
  24. package/dist/esm/Collapse.js +7 -97
  25. package/dist/esm/CollapseItem.js +8 -146
  26. package/dist/esm/ConfigProvider.js +8 -187
  27. package/dist/esm/CountDown.js +9 -247
  28. package/dist/esm/DatePicker.js +25 -309
  29. package/dist/esm/Dialog.js +17 -296
  30. package/dist/esm/Divider.js +7 -34
  31. package/dist/esm/Drag.js +7 -118
  32. package/dist/esm/Elevator.js +8 -234
  33. package/dist/esm/Ellipsis.js +10 -176
  34. package/dist/esm/Empty.js +8 -79
  35. package/dist/esm/FixedNav.js +14 -103
  36. package/dist/esm/Form.js +10 -215
  37. package/dist/esm/FormItem.js +10 -3
  38. package/dist/esm/Grid.js +11 -81
  39. package/dist/esm/GridItem.js +13 -123
  40. package/dist/esm/Icon.js +5 -2
  41. package/dist/esm/Image.js +11 -169
  42. package/dist/esm/ImagePreview.js +19 -225
  43. package/dist/esm/Indicator.js +7 -50
  44. package/dist/esm/Infiniteloading.js +14 -215
  45. package/dist/esm/Input.js +12 -362
  46. package/dist/esm/InputNumber.js +9 -275
  47. package/dist/esm/Layout.js +5 -13
  48. package/dist/esm/Menu.js +10 -153
  49. package/dist/esm/MenuItem.js +15 -175
  50. package/dist/esm/NavBar.js +9 -114
  51. package/dist/esm/NoticeBar.js +10 -568
  52. package/dist/esm/Notify.js +8 -234
  53. package/dist/esm/NumberKeyboard.js +17 -247
  54. package/dist/esm/Overlay.js +6 -2
  55. package/dist/esm/Pagination.js +9 -168
  56. package/dist/esm/Picker.js +22 -494
  57. package/dist/esm/Popover.js +12 -223
  58. package/dist/esm/Popup.js +13 -193
  59. package/dist/esm/Price.js +6 -84
  60. package/dist/esm/Progress.js +9 -122
  61. package/dist/esm/PullToRefresh.js +13 -276
  62. package/dist/esm/Radio.js +8 -4
  63. package/dist/esm/RadioGroup.js +7 -120
  64. package/dist/esm/Range.js +15 -406
  65. package/dist/esm/Rate.js +9 -121
  66. package/dist/esm/Row.js +7 -49
  67. package/dist/esm/SearchBar.js +12 -235
  68. package/dist/esm/ShortPassword.js +17 -191
  69. package/dist/esm/SideNavBar.js +19 -57
  70. package/dist/esm/SideNavBarItem.js +5 -24
  71. package/dist/esm/Signature.js +13 -153
  72. package/dist/esm/Skeleton.js +12 -98
  73. package/dist/esm/Step.js +10 -87
  74. package/dist/esm/Steps.js +8 -38
  75. package/dist/esm/Sticky.js +11 -190
  76. package/dist/esm/SubSideNavBar.js +6 -78
  77. package/dist/esm/Swipe.js +10 -230
  78. package/dist/esm/Swiper.js +9 -490
  79. package/dist/esm/SwiperItem.js +8 -36
  80. package/dist/esm/Switch.js +6 -71
  81. package/dist/esm/TabPane.js +5 -2
  82. package/dist/esm/Tabbar.js +6 -68
  83. package/dist/esm/TabbarItem.js +9 -78
  84. package/dist/esm/Table.js +12 -140
  85. package/dist/esm/Tabs.js +8 -5
  86. package/dist/esm/Tag.js +10 -110
  87. package/dist/esm/TextArea.js +9 -148
  88. package/dist/esm/TimeDetail.js +9 -67
  89. package/dist/esm/TimePannel.js +9 -29
  90. package/dist/esm/TimeSelect.js +19 -171
  91. package/dist/esm/Toast.js +7 -268
  92. package/dist/esm/TrendArrow.js +7 -99
  93. package/dist/esm/Uploader.js +17 -566
  94. package/dist/esm/{UserContext-101ad4a4.js → UserContext-0aac9a82.js} +3 -1
  95. package/dist/esm/{UserContext-2629d479.js → UserContext-e402e1a6.js} +3 -1
  96. package/dist/esm/{UserContext-b33bcf21.js → UserContext-e8176108.js} +3 -1
  97. package/dist/esm/Video.js +7 -90
  98. package/dist/esm/VirtualList.js +9 -313
  99. package/dist/esm/WaterMark.js +11 -111
  100. package/dist/esm/actionsheet.taro-e6a51446.js +53 -0
  101. package/dist/esm/address.taro-3a9b6396.js +461 -0
  102. package/dist/esm/animate.taro-fb7986d6.js +40 -0
  103. package/dist/esm/animatingnumbers.taro-03e5d61d.js +104 -0
  104. package/dist/esm/audio.taro-87ec8bf2.js +161 -0
  105. package/dist/esm/avatar.taro-3676f38f.js +103 -0
  106. package/dist/esm/avatargroup-f3574510.js +34 -0
  107. package/dist/esm/backtop.taro-66394a36.js +48 -0
  108. package/dist/esm/badge.taro-a4e59c11.js +52 -0
  109. package/dist/esm/barrage.taro-0495a1b2.js +94 -0
  110. package/dist/esm/{bem-3b438e61.js → bem-350c1702.js} +3 -6
  111. package/dist/esm/button.taro-9244d065.js +100 -0
  112. package/dist/esm/calendar.taro-670842ea.js +65 -0
  113. package/dist/esm/calendaritem.taro-2a603571.js +787 -0
  114. package/dist/esm/can-use-dom-3eeb5af4.js +6 -0
  115. package/dist/esm/card.taro-e4c76dad.js +33 -0
  116. package/dist/esm/cascader.taro-eb1fb011.js +438 -0
  117. package/dist/esm/cell.taro-a10a74d3.js +64 -0
  118. package/dist/esm/cellgroup.taro-abe501bc.js +25 -0
  119. package/dist/esm/checkbox.taro-6120e3e3.js +171 -0
  120. package/dist/esm/circleprogress.taro-79854448.js +109 -0
  121. package/dist/esm/col.taro-53eed3cc.js +41 -0
  122. package/dist/esm/collapse.taro-1a9e4ba2.js +83 -0
  123. package/dist/esm/collapseitem-4d0bc55d.js +83 -0
  124. package/dist/esm/configprovider-67d19d3a.js +19 -0
  125. package/dist/esm/configprovider.taro-8d71eb49.js +42 -0
  126. package/dist/esm/countdown.taro-5b17c607.js +226 -0
  127. package/dist/esm/datepicker.taro-6e9b4b8f.js +275 -0
  128. package/dist/esm/dialog.taro-a3267d29.js +118 -0
  129. package/dist/esm/divider.taro-26d1d8b4.js +35 -0
  130. package/dist/esm/drag.taro-79bb8744.js +110 -0
  131. package/dist/esm/elevator.taro-6019669e.js +178 -0
  132. package/dist/esm/ellipsis.taro-f15f26da.js +241 -0
  133. package/dist/esm/empty.taro-04ae4389.js +62 -0
  134. package/dist/esm/fixednav.taro-1f05acaf.js +53 -0
  135. package/dist/esm/form.taro-0c8e7a39.js +179 -0
  136. package/dist/esm/formitem.taro-190a3326.js +89 -0
  137. package/dist/esm/get-scroll-parent-b4a07e65.js +25 -0
  138. package/dist/esm/grid.taro-3503b82c.js +61 -0
  139. package/dist/esm/{grid.context-2ee27d95.js → grid.taro.context-c2bbfb4f.js} +4 -2
  140. package/dist/esm/griditem.taro-cdb3f119.js +98 -0
  141. package/dist/esm/icon-296a1bec.js +63 -0
  142. package/dist/esm/icon.taro-296a1bec.js +63 -0
  143. package/dist/esm/image.taro-142cf512.js +64 -0
  144. package/dist/esm/imagepreview.taro-c50bb0a3.js +167 -0
  145. package/dist/esm/index-5bcb0ff8.js +7 -0
  146. package/dist/esm/indicator.taro-cba8b010.js +37 -0
  147. package/dist/esm/infiniteloading.taro-183bccbf.js +144 -0
  148. package/dist/esm/input.taro-97af6c96.js +240 -0
  149. package/dist/esm/inputnumber.taro-91f65d17.js +130 -0
  150. package/dist/esm/layout.taro-9046d093.js +11 -0
  151. package/dist/esm/menu.taro-7e4038a1.js +99 -0
  152. package/dist/esm/menuitem.taro-96cc4f15.js +130 -0
  153. package/dist/esm/navbar.taro-777c4705.js +79 -0
  154. package/dist/esm/noticebar.taro-4a23cdee.js +448 -0
  155. package/dist/esm/notify.taro-e17c6f82.js +75 -0
  156. package/dist/esm/numberkeyboard.taro-1bc24744.js +159 -0
  157. package/dist/esm/nutui-react.es.js +119 -94
  158. package/dist/esm/offsetContext-c2a746fa.js +5 -0
  159. package/dist/esm/overlay.taro-21e87fb1.js +69 -0
  160. package/dist/esm/pagination.taro-715a173b.js +124 -0
  161. package/dist/esm/picker.taro-9ad1b7c5.js +473 -0
  162. package/dist/esm/popover.taro-ad5e76ea.js +156 -0
  163. package/dist/esm/popup.taro-01676bff.js +137 -0
  164. package/dist/esm/price.taro-776ed16e.js +83 -0
  165. package/dist/esm/progress.taro-f0ce38e9.js +90 -0
  166. package/dist/esm/pulltorefresh.taro-a294f656.js +181 -0
  167. package/dist/esm/radio.taro-a6eff96c.js +168 -0
  168. package/dist/esm/range.taro-d8fc7656.js +332 -0
  169. package/dist/esm/rate.taro-6cdf03bd.js +75 -0
  170. package/dist/esm/row.taro-f64d4a13.js +46 -0
  171. package/dist/esm/searchbar.taro-0c25927b.js +152 -0
  172. package/dist/esm/shortpassword.taro-9ee034f7.js +111 -0
  173. package/dist/esm/sidenavbar.taro-c307b35e.js +35 -0
  174. package/dist/esm/sidenavbaritem.taro-5a7965d0.js +12 -0
  175. package/dist/esm/signature.taro-ec4e713b.js +143 -0
  176. package/dist/esm/skeleton.taro-76faf63f.js +62 -0
  177. package/dist/esm/step.taro-b7903e8c.js +59 -0
  178. package/dist/esm/steps.taro-c82d2252.js +30 -0
  179. package/dist/esm/sticky.taro-218bda37.js +138 -0
  180. package/dist/esm/subsidenavbar.taro-69cb9752.js +63 -0
  181. package/dist/esm/supports-passive-c85ef996.js +18 -0
  182. package/dist/esm/swipe.taro-ea35f07f.js +177 -0
  183. package/dist/esm/swiper.taro-7a94e211.js +451 -0
  184. package/dist/esm/swiperitem-c9e3d0d5.js +29 -0
  185. package/dist/esm/switch.taro-34ca8228.js +50 -0
  186. package/dist/esm/tabbar.taro-9acfc2fa.js +59 -0
  187. package/dist/esm/tabbaritem.taro-bf517487.js +58 -0
  188. package/dist/esm/table.taro-91fc0c01.js +93 -0
  189. package/dist/esm/tabpane.taro-4ca340ef.js +23 -0
  190. package/dist/esm/tabs.taro-6a7524a4.js +140 -0
  191. package/dist/esm/tag.taro-23ba0834.js +92 -0
  192. package/dist/esm/textarea.taro-442e7350.js +94 -0
  193. package/dist/esm/timedetail.taro-5b2f2269.js +44 -0
  194. package/dist/esm/timepannel.taro-d6e40180.js +22 -0
  195. package/dist/esm/timeselect.taro-a07036f4.js +133 -0
  196. package/dist/esm/toast.taro-d6c14811.js +109 -0
  197. package/dist/esm/trendarrow.taro-b8c5ccd9.js +73 -0
  198. package/dist/esm/typings-b9828dba.js +9 -0
  199. package/dist/esm/uploader.taro-587e6bf3.js +492 -0
  200. package/dist/esm/useClientRect-1f8ed1fe.js +18 -0
  201. package/dist/esm/useTouch-db24bb5c.js +69 -0
  202. package/dist/esm/video-f1be8a91.js +67 -0
  203. package/dist/esm/virtuallist.taro-f0b0270d.js +214 -0
  204. package/dist/esm/watermark.taro-9ce2ae37.js +114 -0
  205. package/dist/esm/zh-CN-c779e6c1.js +131 -0
  206. package/dist/locales/base.js +1 -1
  207. package/dist/locales/en-US.js +1 -1
  208. package/dist/locales/id-ID.js +1 -1
  209. package/dist/locales/zh-CN.js +1 -1
  210. package/dist/locales/zh-TW.js +1 -1
  211. package/dist/locales/zh-UG.js +1 -1
  212. package/dist/nutui.react.mjs +13030 -14863
  213. package/dist/nutui.react.umd.js +13029 -14864
  214. package/dist/style.mjs +1 -1
  215. package/dist/types/index.d.ts +176 -183
  216. package/package.json +1 -1
  217. package/dist/esm/cellgroup-fcc72767.js +0 -34
  218. package/dist/esm/checkbox-44e13cd0.js +0 -137
  219. package/dist/esm/date-c7aad4c0.js +0 -97
  220. package/dist/esm/formitem-8a73a5fb.js +0 -157
  221. package/dist/esm/get-scroll-parent-5f85dee8.js +0 -24
  222. package/dist/esm/icon-4ef1581c.js +0 -70
  223. package/dist/esm/index-030b7245.js +0 -11
  224. package/dist/esm/offsetContext-3ab00d40.js +0 -16
  225. package/dist/esm/overlay-de6c79d5.js +0 -83
  226. package/dist/esm/radio-9f141e6b.js +0 -118
  227. package/dist/esm/render-bbebb760.js +0 -79
  228. package/dist/esm/tabpane-01075e6c.js +0 -29
  229. package/dist/esm/tabs-e1b4e4b1.js +0 -181
  230. package/dist/esm/typings-f27b58f4.js +0 -8
  231. package/dist/esm/useClientRect-56bb675b.js +0 -39
  232. package/dist/esm/useTouch-cf73a407.js +0 -99
@@ -0,0 +1,332 @@
1
+ import React__default, { useState, useRef, useEffect, useCallback } from 'react';
2
+ import { u as useTouch } from './useTouch-db24bb5c.js';
3
+ import { g as getRectByTaro } from './useClientRect-1f8ed1fe.js';
4
+ import { T as Toast } from './toast.taro-d6c14811.js';
5
+ import { u as useConfig } from './configprovider.taro-8d71eb49.js';
6
+
7
+ const defaultProps = {
8
+ range: false,
9
+ hiddenRange: false,
10
+ hiddenTag: false,
11
+ min: 0,
12
+ max: 100,
13
+ step: 1,
14
+ modelValue: 0,
15
+ vertical: false,
16
+ marks: {},
17
+ };
18
+ let startValue;
19
+ let currentValue;
20
+ const Range = (props) => {
21
+ const { locale } = useConfig();
22
+ const { className, range, disabled, activeColor, inactiveColor, buttonColor, hiddenRange, hiddenTag, modelValue, button, vertical, marks, dragStart, dragEnd, onChange, onDragStart, onDragEnd, minDesc, maxDesc, curValueDesc, } = { ...defaultProps, ...props };
23
+ let { min, max, step } = { ...defaultProps, ...props };
24
+ min = Number(min);
25
+ max = Number(max);
26
+ step = Number(step);
27
+ const [buttonIndex, SetButtonIndex] = useState(0);
28
+ const [initValue, SetInitValue] = useState();
29
+ const [dragStatus, SetDragStatus] = useState('start' );
30
+ const touch = useTouch();
31
+ const root = useRef(null);
32
+ const [marksList, SetMarksList] = useState([]);
33
+ const [show, SetShow] = useState(false);
34
+ const [toastMsg, SetToastMsg] = useState('');
35
+ const toastShow = (msg) => {
36
+ SetToastMsg(msg);
37
+ SetShow(true);
38
+ };
39
+ useEffect(() => {
40
+ if (typeof modelValue === 'number') {
41
+ if (!range && (modelValue < min || modelValue > max)) {
42
+ SetInitValue(0);
43
+ toastShow(`${modelValue} ${locale.range.rangeText}`);
44
+ return;
45
+ }
46
+ SetInitValue(modelValue);
47
+ }
48
+ }, [modelValue]);
49
+ useEffect(() => {
50
+ if (marks) {
51
+ const marksKeys = Object.keys(marks);
52
+ const list = marksKeys
53
+ .map(parseFloat)
54
+ .sort((a, b) => a - b)
55
+ .filter((point) => point >= min && point <= max);
56
+ SetMarksList(list);
57
+ }
58
+ }, [marks]);
59
+ const scope = () => {
60
+ return Number(max) - Number(min);
61
+ };
62
+ const classes = useCallback(() => {
63
+ const prefixCls = 'nut-range';
64
+ return [
65
+ prefixCls,
66
+ `${disabled ? `${prefixCls}-disabled` : ''}`,
67
+ `${vertical ? `${prefixCls}-vertical` : ''}`,
68
+ `${!hiddenRange ? `${prefixCls}-show-number` : ''}`,
69
+ ]
70
+ .filter(Boolean)
71
+ .join(' ');
72
+ }, [disabled, vertical, hiddenRange]);
73
+ const containerClasses = useCallback(() => {
74
+ const prefixCls = 'nut-range-container';
75
+ return [prefixCls, `${vertical ? `${prefixCls}-vertical` : ''}`, className]
76
+ .filter(Boolean)
77
+ .join(' ');
78
+ }, [vertical, className]);
79
+ const markClassName = useCallback((mark) => {
80
+ const classPrefix = 'nut-range-mark';
81
+ let lowerBound = Number(min);
82
+ let upperBound = Number(max);
83
+ if (range) {
84
+ const [left, right] = modelValue;
85
+ lowerBound = left;
86
+ upperBound = right;
87
+ }
88
+ else {
89
+ upperBound = modelValue;
90
+ }
91
+ const isActive = mark <= upperBound && mark >= lowerBound;
92
+ return [
93
+ `${classPrefix}-text`,
94
+ `${isActive ? `${classPrefix}-text-active` : ''}`,
95
+ ]
96
+ .filter(Boolean)
97
+ .join(' ');
98
+ }, [range, modelValue, min, max]);
99
+ const [rangeName, setRangeName] = useState(classes());
100
+ const [containerName, setContainerName] = useState(containerClasses());
101
+ useEffect(() => {
102
+ setRangeName(classes());
103
+ setContainerName(containerClasses());
104
+ }, [classes, containerClasses]);
105
+ const wrapperStyle = () => {
106
+ return {
107
+ background: inactiveColor,
108
+ };
109
+ };
110
+ const buttonStyle = () => {
111
+ return {
112
+ borderColor: buttonColor,
113
+ };
114
+ };
115
+ const isRange = (val) => {
116
+ return !!range && Array.isArray(val);
117
+ };
118
+ const calcMainAxis = () => {
119
+ const modelVal = initValue || initValue === 0 ? initValue : modelValue;
120
+ if (isRange(modelVal)) {
121
+ return `${((modelVal[1] - modelVal[0]) * 100) / scope()}%`;
122
+ }
123
+ return `${((modelVal - Number(min)) * 100) / scope()}%`;
124
+ };
125
+ const calcOffset = () => {
126
+ const modelVal = initValue || initValue === 0 ? initValue : modelValue;
127
+ if (isRange(modelVal)) {
128
+ return `${((modelVal[0] - Number(min)) * 100) / scope()}%`;
129
+ }
130
+ return `0%`;
131
+ };
132
+ const barStyle = () => {
133
+ if (vertical) {
134
+ return {
135
+ height: calcMainAxis(),
136
+ top: calcOffset(),
137
+ background: activeColor,
138
+ transition: dragStatus ? 'none' : undefined,
139
+ };
140
+ }
141
+ return {
142
+ width: calcMainAxis(),
143
+ left: calcOffset(),
144
+ background: activeColor,
145
+ transition: dragStatus ? 'none' : undefined,
146
+ };
147
+ };
148
+ const marksStyle = (mark) => {
149
+ let style = {
150
+ left: `${((mark - Number(min)) / scope()) * 100}%`,
151
+ };
152
+ if (vertical) {
153
+ style = {
154
+ top: `${((mark - Number(min)) / scope()) * 100}%`,
155
+ };
156
+ }
157
+ return style;
158
+ };
159
+ const tickStyle = (mark) => {
160
+ let lowerBound = Number(min);
161
+ let upperBound = Number(max);
162
+ if (range) {
163
+ const [left, right] = modelValue;
164
+ lowerBound = left;
165
+ upperBound = right;
166
+ }
167
+ const isActive = mark <= upperBound && mark >= lowerBound;
168
+ const style = {
169
+ background: !isActive ? inactiveColor : activeColor,
170
+ };
171
+ return style;
172
+ };
173
+ const format = (value) => {
174
+ value = Math.max(+min, Math.min(value, +max));
175
+ return Math.round(value / +step) * +step;
176
+ };
177
+ const isSameValue = (newValue, oldValue) => {
178
+ return JSON.stringify(newValue) === JSON.stringify(oldValue);
179
+ };
180
+ const handleOverlap = (value) => {
181
+ if (value[0] > value[1]) {
182
+ return value.slice(0).reverse();
183
+ }
184
+ return value;
185
+ };
186
+ const updateValue = (value, end) => {
187
+ if (isRange(value)) {
188
+ value = handleOverlap(value).map(format);
189
+ }
190
+ else {
191
+ value = format(value);
192
+ }
193
+ const modelVal = initValue || initValue === 0 ? initValue : modelValue;
194
+ if (!isSameValue(value, modelVal)) {
195
+ SetInitValue(value);
196
+ }
197
+ if ((marks || end) && !isSameValue(value, startValue)) {
198
+ onChange && onChange(value);
199
+ }
200
+ };
201
+ const click = async (event) => {
202
+ if (disabled || !root.current) {
203
+ return;
204
+ }
205
+ SetDragStatus('');
206
+ const rect = await getRectByTaro(root.current);
207
+ let delta = (event.detail.x ? event.detail.x : event.clientX) - rect.left;
208
+ let total = rect.width;
209
+ if (vertical) {
210
+ delta = (event.detail.y ? event.detail.y : event.clientY) - rect.top;
211
+ total = rect.height;
212
+ }
213
+ const value = Number(min) + (delta / total) * scope();
214
+ currentValue = initValue || initValue === 0 ? initValue : modelValue;
215
+ if (isRange(currentValue)) {
216
+ const [left, right] = currentValue;
217
+ const middle = (left + right) / 2;
218
+ if (value <= middle) {
219
+ updateValue([value, right], true);
220
+ }
221
+ else {
222
+ updateValue([left, value], true);
223
+ }
224
+ }
225
+ else {
226
+ updateValue(value, true);
227
+ }
228
+ };
229
+ const onTouchStart = (event) => {
230
+ if (disabled) {
231
+ return;
232
+ }
233
+ touch.start(event);
234
+ currentValue = initValue || initValue === 0 ? initValue : modelValue;
235
+ if (isRange(currentValue)) {
236
+ startValue = currentValue.map(format);
237
+ }
238
+ else {
239
+ startValue = format(currentValue);
240
+ }
241
+ SetDragStatus('start');
242
+ };
243
+ const onTouchMove = async (event) => {
244
+ if (disabled || !root.current) {
245
+ return;
246
+ }
247
+ if (dragStatus === 'start') {
248
+ dragStart && dragStart();
249
+ onDragStart && onDragStart();
250
+ }
251
+ touch.move(event);
252
+ SetDragStatus('draging');
253
+ const rect = await getRectByTaro(root.current);
254
+ let delta = touch.deltaX;
255
+ let total = rect.width;
256
+ let diff = (delta / total) * scope();
257
+ if (vertical) {
258
+ delta = touch.deltaY;
259
+ total = rect.height;
260
+ diff = (delta / total) * scope();
261
+ }
262
+ if (isRange(startValue)) {
263
+ currentValue[buttonIndex] = startValue[buttonIndex] + diff;
264
+ }
265
+ else {
266
+ currentValue = startValue + diff;
267
+ }
268
+ updateValue(currentValue);
269
+ };
270
+ const onTouchEnd = (event) => {
271
+ if (disabled) {
272
+ return;
273
+ }
274
+ if (dragStatus === 'draging') {
275
+ updateValue(currentValue, true);
276
+ dragEnd && dragEnd();
277
+ onDragEnd && onDragEnd();
278
+ }
279
+ SetDragStatus('');
280
+ };
281
+ const curValue = (idx) => {
282
+ const modelVal = initValue || initValue === 0 ? initValue : modelValue;
283
+ const value = typeof idx === 'number' ? modelVal[idx] : modelVal;
284
+ return value;
285
+ };
286
+ return (React__default.createElement("div", { className: `${containerName}` },
287
+ !hiddenRange ? React__default.createElement("div", { className: "min" }, minDesc || +min) : null,
288
+ React__default.createElement("div", { ref: root, style: wrapperStyle(), className: `${rangeName}`, onClick: (e) => {
289
+ click(e);
290
+ } },
291
+ marksList.length > 0 ? (React__default.createElement("div", { className: "nut-range-mark" }, marksList.map((marks) => {
292
+ return (React__default.createElement("span", { key: marks, className: markClassName(marks), style: marksStyle(marks) },
293
+ marks,
294
+ React__default.createElement("span", { className: "nut-range-tick", style: tickStyle(marks) })));
295
+ }))) : null,
296
+ React__default.createElement("div", { className: "nut-range-bar", style: barStyle() }, range ? ([0, 1].map((item, index) => {
297
+ return (React__default.createElement("div", { role: "slider", key: index, className: `${index === 0 ? 'nut-range-button-wrapper-left' : ''}
298
+ ${index === 1 ? 'nut-range-button-wrapper-right' : ''}`, tabIndex: disabled ? -1 : 0, "aria-valuemin": +min, "aria-valuenow": curValue(index), "aria-valuemax": +max, "aria-orientation": vertical ? 'vertical' : 'horizontal', onTouchStart: (e) => {
299
+ if (typeof index === 'number') {
300
+ // 实时更新当前拖动的按钮索引
301
+ SetButtonIndex(index);
302
+ }
303
+ onTouchStart(e);
304
+ }, onTouchMove: (e) => {
305
+ onTouchMove(e);
306
+ }, onTouchEnd: (e) => {
307
+ onTouchEnd();
308
+ }, onTouchCancel: (e) => {
309
+ onTouchEnd();
310
+ }, onClick: (e) => {
311
+ e.stopPropagation();
312
+ } }, button || (React__default.createElement("div", { className: "nut-range-button", style: buttonStyle() }, !hiddenTag ? (React__default.createElement("div", { className: "number" }, curValueDesc || curValue(index))) : null))));
313
+ })) : (React__default.createElement("div", { role: "slider", className: "nut-range-button-wrapper", tabIndex: disabled ? -1 : 0, "aria-valuemin": +min, "aria-valuenow": curValue(), "aria-valuemax": +max, "aria-orientation": vertical ? 'vertical' : 'horizontal', onTouchStart: (e) => {
314
+ onTouchStart(e);
315
+ }, onTouchMove: (e) => {
316
+ onTouchMove(e);
317
+ }, onTouchEnd: (e) => {
318
+ onTouchEnd();
319
+ }, onTouchCancel: (e) => {
320
+ onTouchEnd();
321
+ }, onClick: (e) => {
322
+ e.stopPropagation();
323
+ } }, button || (React__default.createElement("div", { className: "nut-range-button", style: buttonStyle() }, !hiddenTag ? (React__default.createElement("div", { className: "number" }, curValueDesc || curValue())) : null)))))),
324
+ !hiddenRange ? React__default.createElement("div", { className: "max" }, maxDesc || +max) : null,
325
+ React__default.createElement(Toast, { type: "text", visible: show, msg: toastMsg, onClose: () => {
326
+ SetShow(false);
327
+ } })));
328
+ };
329
+ Range.defaultProps = defaultProps;
330
+ Range.displayName = 'NutRange';
331
+
332
+ export { Range as R };
@@ -0,0 +1,75 @@
1
+ import React__default, { useState, useEffect } from 'react';
2
+ import classNames from 'classnames';
3
+ import { c as cn } from './bem-350c1702.js';
4
+ import { I as Icon } from './icon-296a1bec.js';
5
+ import { C as ComponentDefaults } from './typings-b9828dba.js';
6
+
7
+ const defaultProps = {
8
+ ...ComponentDefaults,
9
+ count: 5,
10
+ modelValue: 0,
11
+ minimizeValue: 0,
12
+ iconSize: 18,
13
+ activeColor: '',
14
+ voidColor: '',
15
+ checkedIcon: 'star-fill-n',
16
+ uncheckedIcon: 'star-n',
17
+ disabled: false,
18
+ readonly: false,
19
+ allowHalf: false,
20
+ spacing: 14,
21
+ };
22
+ const Rate = (props) => {
23
+ const { className, style, count, modelValue, minimizeValue, iconSize, activeColor, voidColor, checkedIcon, uncheckedIcon, disabled, readonly, allowHalf, spacing, onChange, iconClassPrefix, iconFontClassName, } = {
24
+ ...defaultProps,
25
+ ...props,
26
+ };
27
+ const b = cn('rate');
28
+ const bi = cn('rate-item');
29
+ const [countArray, setCountArray] = useState([1, 2, 3, 4, 5]);
30
+ const [score, setScore] = useState(0);
31
+ useEffect(() => {
32
+ const tmp = [];
33
+ for (let i = 1; i <= Number(count); i++) {
34
+ tmp.push(i);
35
+ }
36
+ setCountArray(tmp);
37
+ }, [count]);
38
+ useEffect(() => {
39
+ setScore(Math.max(Number(modelValue), Number(minimizeValue)));
40
+ }, [modelValue]);
41
+ const pxCheck = (value) => {
42
+ return Number.isNaN(Number(value)) ? String(value) : `${value}px`;
43
+ };
44
+ const onClick = (e, index) => {
45
+ e.preventDefault();
46
+ e.stopPropagation();
47
+ if (disabled || readonly)
48
+ return;
49
+ let value = 0;
50
+ if (!(index === 1 && score === index)) {
51
+ value = index;
52
+ }
53
+ value = Math.max(value, Number(minimizeValue));
54
+ setScore(value);
55
+ onChange && onChange(value);
56
+ };
57
+ const onHalfClick = (event, n) => {
58
+ event.preventDefault();
59
+ event.stopPropagation();
60
+ const value = Math.max(Number(minimizeValue), n - 0.5);
61
+ setScore(value);
62
+ onChange && onChange(value);
63
+ };
64
+ return (React__default.createElement("div", { className: classNames(b(), className), style: style }, countArray.map((n) => {
65
+ return (React__default.createElement("div", { className: bi(), key: n, onClick: (event) => onClick(event, n), style: { marginRight: pxCheck(spacing) } },
66
+ React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, size: iconSize, className: classNames(bi('icon'), {
67
+ [bi('icon--disabled')]: disabled || n > score,
68
+ }), name: n <= score ? checkedIcon : uncheckedIcon, color: n <= score ? activeColor : voidColor }),
69
+ allowHalf && score > n - 1 && (React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, onClick: (event) => onHalfClick(event, n), className: `${bi('icon')} ${bi('icon--half')}`, color: n <= score ? activeColor : voidColor, size: iconSize, name: checkedIcon }))));
70
+ })));
71
+ };
72
+ Rate.defaultProps = defaultProps;
73
+ Rate.displayName = 'NutRate';
74
+
75
+ export { Rate as R };
@@ -0,0 +1,46 @@
1
+ import React__default from 'react';
2
+ import classNames from 'classnames';
3
+ import { D as DataContext } from './UserContext-0aac9a82.js';
4
+
5
+ const defaultProps = {
6
+ type: '',
7
+ justify: 'start',
8
+ align: 'flex-start',
9
+ wrap: 'nowrap',
10
+ gutter: '0',
11
+ };
12
+ const Row = (props) => {
13
+ const { className, style = {}, children, type, justify, align, wrap, gutter, onClick, } = {
14
+ ...defaultProps,
15
+ ...props,
16
+ };
17
+ const prefixCls = 'nut-row';
18
+ const getClass = (prefix, type) => {
19
+ const classType = type ? `nut-row-${prefix}-${type}` : '';
20
+ const className = prefix ? classType : `nut-row-${type}`;
21
+ return className;
22
+ };
23
+ const getClasses = () => {
24
+ return `
25
+ ${getClass('', type)}
26
+ ${getClass('justify', justify)}
27
+ ${getClass('align', align)}
28
+ ${getClass('flex', wrap)}
29
+ ${prefixCls}
30
+ `;
31
+ };
32
+ const parentRow = {
33
+ gutter,
34
+ };
35
+ return (React__default.createElement(DataContext.Provider, { value: parentRow }, React__default.createElement('div', {
36
+ className: classNames(getClasses(), className),
37
+ style,
38
+ onClick: (e) => {
39
+ onClick && onClick(e, 'row');
40
+ },
41
+ }, children)));
42
+ };
43
+ Row.defaultProps = defaultProps;
44
+ Row.displayName = 'NutRow';
45
+
46
+ export { Row as R };
@@ -0,0 +1,152 @@
1
+ import React__default, { useRef, useState, useEffect } from 'react';
2
+ import { getEnv } from '@tarojs/taro';
3
+ import { c as cn } from './bem-350c1702.js';
4
+ import { u as useConfig } from './configprovider.taro-8d71eb49.js';
5
+ import { I as Icon } from './icon.taro-296a1bec.js';
6
+ import { C as ComponentDefaults } from './typings-b9828dba.js';
7
+
8
+ const defaultProps = {
9
+ ...ComponentDefaults,
10
+ placeholder: '',
11
+ shape: 'square',
12
+ disabled: false,
13
+ maxLength: 9999,
14
+ clearable: true,
15
+ clearIconSize: '12px',
16
+ align: 'left',
17
+ readonly: true,
18
+ autoFocus: false,
19
+ label: '',
20
+ leftinIcon: React__default.createElement(Icon, { name: "search", size: "12" }),
21
+ };
22
+ const SearchBar = (props) => {
23
+ const searchbarBem = cn('searchbar');
24
+ const { locale } = useConfig();
25
+ const searchRef = useRef(null);
26
+ const [value, setValue] = useState(() => props.value);
27
+ const { placeholder, shape, className, disabled, maxLength, clearable, clearIconSize, align, readOnly, autoFocus, label, actionText, leftinIcon, rightinIcon, leftoutIcon, rightoutIcon, onChange, onFocus, onBlur, onClear, onCancel, onSearch, onClickInput, onClickLeftinIcon, onClickLeftoutIcon, onClickRightinIcon, onClickRightoutIcon, iconClassPrefix, iconFontClassName, } = {
28
+ ...defaultProps,
29
+ ...props,
30
+ };
31
+ const alignClass = `${align}`;
32
+ const forceFocus = () => {
33
+ const searchSelf = searchRef.current;
34
+ searchSelf && searchSelf.focus();
35
+ };
36
+ const change = (event) => {
37
+ const { value } = event.target;
38
+ onChange && onChange?.(value, event);
39
+ setValue(value);
40
+ value === '' && forceFocus();
41
+ };
42
+ const focus = (event) => {
43
+ const { value } = event.target;
44
+ onFocus && onFocus?.(value, event);
45
+ };
46
+ const blur = (event) => {
47
+ const searchSelf = searchRef.current;
48
+ searchSelf && searchSelf.blur();
49
+ const { value } = event.target;
50
+ onBlur && onBlur?.(value, event);
51
+ };
52
+ useEffect(() => {
53
+ setValue(props.value);
54
+ }, [props.value]);
55
+ useEffect(() => {
56
+ autoFocus && forceFocus();
57
+ }, [autoFocus]);
58
+ const renderField = () => {
59
+ return (React__default.createElement("input", { className: `${searchbarBem('input')} ${searchbarBem(alignClass)} ${shape === 'round' ? searchbarBem('round') : ''} ${clearable ? searchbarBem('input-clear') : ''}`, ref: searchRef, style: { ...props.style }, value: value || '', placeholder: placeholder || locale.placeholder, disabled: disabled, readOnly: readOnly, maxLength: maxLength, onKeyPress: onKeypress, onChange: (e) => change(e), onFocus: (e) => focus(e), onBlur: (e) => blur(e), onClick: (e) => clickInput(e) }));
60
+ };
61
+ const clickInput = (e) => {
62
+ onClickInput && onClickInput(e);
63
+ };
64
+ const renderLeftinIcon = () => {
65
+ if (!leftinIcon)
66
+ return null;
67
+ return (React__default.createElement("div", { className: `${searchbarBem('leftin-icon')} ${searchbarBem('icon')}`, onClick: (e) => clickLeftIcon('in-left', e) }, leftinIcon));
68
+ };
69
+ const renderLeftoutIcon = () => {
70
+ if (!leftoutIcon)
71
+ return null;
72
+ return (React__default.createElement("div", { className: `${searchbarBem('leftout-icon')}`, onClick: (e) => clickLeftIcon('out-left', e) }, leftoutIcon));
73
+ };
74
+ const clickLeftIcon = (flag, event) => {
75
+ if (flag === 'in-left') {
76
+ onClickLeftinIcon && onClickLeftinIcon(value, event);
77
+ }
78
+ else {
79
+ onClickLeftoutIcon && onClickLeftoutIcon(value, event);
80
+ }
81
+ };
82
+ const renderRightinIcon = () => {
83
+ if (!rightinIcon)
84
+ return null;
85
+ return (React__default.createElement("div", { className: `${searchbarBem('rightin-icon')} ${searchbarBem('icon')}`, onClick: (e) => clickRightIcon('in-right', e) }, rightinIcon));
86
+ };
87
+ const renderRightoutIcon = () => {
88
+ if (!rightoutIcon)
89
+ return null;
90
+ return (React__default.createElement("div", { className: `${searchbarBem('rightout-icon')}`, onClick: (e) => clickRightIcon('out-right', e) }, rightoutIcon));
91
+ };
92
+ const clickRightIcon = (flag, event) => {
93
+ if (flag === 'in-left') {
94
+ onClickRightinIcon && onClickRightinIcon(value, event);
95
+ }
96
+ else {
97
+ onClickRightoutIcon && onClickRightoutIcon(value, event);
98
+ }
99
+ };
100
+ const handleClear = () => {
101
+ return (React__default.createElement("div", { className: `${searchbarBem('clear')} ${rightinIcon ? 'pos-right' : ''}`, onClick: (e) => clearaVal(e) },
102
+ React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, name: "circle-close", size: clearIconSize, color: "#555" })));
103
+ };
104
+ const clearaVal = (event) => {
105
+ if (disabled || readOnly) {
106
+ return;
107
+ }
108
+ setValue('');
109
+ onClear && onClear(event);
110
+ forceFocus();
111
+ };
112
+ const renderRightLabel = () => {
113
+ if (actionText) {
114
+ return (React__default.createElement("div", { className: searchbarBem('action-text'), onClick: search }, actionText));
115
+ }
116
+ return null;
117
+ };
118
+ const onKeypress = (e) => {
119
+ if (e.keyCode === 13) {
120
+ if (typeof e.cancelable !== 'boolean' || e.cancelable) {
121
+ e.preventDefault();
122
+ }
123
+ onSearch && onSearch(value);
124
+ }
125
+ };
126
+ const search = () => {
127
+ onSearch && onSearch(value);
128
+ };
129
+ const renderLabel = () => {
130
+ if (label) {
131
+ return React__default.createElement("div", { className: searchbarBem('label') }, label);
132
+ }
133
+ return null;
134
+ };
135
+ const envClass = () => {
136
+ return getEnv() === 'WEB' ? 'nut-searchbar-taro' : '';
137
+ };
138
+ return (React__default.createElement("div", { className: `${searchbarBem()} ${envClass()} ${disabled ? searchbarBem('disabled') : ''} ${className || ''}`, style: { ...props.style, background: props.background } },
139
+ renderLeftoutIcon(),
140
+ renderLabel(),
141
+ React__default.createElement("div", { className: `${searchbarBem('content')}`, style: { background: props.inputBackground } },
142
+ renderLeftinIcon(),
143
+ React__default.createElement("div", { className: "nut-searchbar__input-box" }, renderField()),
144
+ renderRightinIcon(),
145
+ clearable && value && handleClear()),
146
+ renderRightoutIcon(),
147
+ renderRightLabel()));
148
+ };
149
+ SearchBar.defaultProps = defaultProps;
150
+ SearchBar.displayName = 'NutSearchBar';
151
+
152
+ export { SearchBar as S };