@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.
Files changed (219) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/esm/Address.js +5 -5
  3. package/dist/esm/Audio.js +5 -5
  4. package/dist/esm/AvatarContext-7153ad2b.js +3 -1
  5. package/dist/esm/AvatarGroup.js +4 -4
  6. package/dist/esm/Calendar.js +5 -5
  7. package/dist/esm/CalendarItem.js +4 -4
  8. package/dist/esm/Card.js +4 -3
  9. package/dist/esm/Cell.js +2 -2
  10. package/dist/esm/ConfigProvider.js +3 -3
  11. package/dist/esm/CountDown.js +4 -4
  12. package/dist/esm/DatePicker.js +5 -5
  13. package/dist/esm/Dialog.js +4 -4
  14. package/dist/esm/Ellipsis.js +4 -4
  15. package/dist/esm/Empty.js +4 -4
  16. package/dist/esm/FixedNav.js +4 -4
  17. package/dist/esm/Form.js +4 -4
  18. package/dist/esm/FormItem.js +3 -3
  19. package/dist/esm/Grid.js +4 -4
  20. package/dist/esm/GridItem.js +4 -4
  21. package/dist/esm/Image.js +4 -4
  22. package/dist/esm/Infiniteloading.js +4 -4
  23. package/dist/esm/Input.js +4 -4
  24. package/dist/esm/MenuItem.js +4 -4
  25. package/dist/esm/NoticeBar.js +2 -2
  26. package/dist/esm/NumberKeyboard.js +4 -4
  27. package/dist/esm/Pagination.js +4 -4
  28. package/dist/esm/Picker.js +4 -4
  29. package/dist/esm/PullToRefresh.js +4 -4
  30. package/dist/esm/Range.js +4 -4
  31. package/dist/esm/SearchBar.js +4 -4
  32. package/dist/esm/ShortPassword.js +4 -4
  33. package/dist/esm/SideNavBar.js +4 -4
  34. package/dist/esm/Signature.js +4 -4
  35. package/dist/esm/Sticky.js +4 -4
  36. package/dist/esm/Table.js +4 -4
  37. package/dist/esm/Tag.js +3 -2
  38. package/dist/esm/TextArea.js +4 -4
  39. package/dist/esm/TimeDetail.js +4 -4
  40. package/dist/esm/TimePannel.js +4 -4
  41. package/dist/esm/TimeSelect.js +6 -6
  42. package/dist/esm/Uploader.js +4 -4
  43. package/dist/esm/UserContext-68f62e66.js +3 -1
  44. package/dist/esm/UserContext-b4181162.js +3 -1
  45. package/dist/esm/UserContext-be8097d2.js +3 -1
  46. package/dist/esm/VirtualList.js +6 -4
  47. package/dist/esm/WaterMark.js +4 -4
  48. package/dist/esm/actionsheet.taro-a58d3d12.js +45 -83
  49. package/dist/esm/address.taro-79cc7c96.js +461 -0
  50. package/dist/esm/animate.taro-b0e83dd5.js +32 -46
  51. package/dist/esm/animatingnumbers.taro-6f40a2e9.js +93 -134
  52. package/dist/esm/audio.taro-4fadc583.js +161 -0
  53. package/dist/esm/avatar.taro-85ced995.js +93 -119
  54. package/dist/esm/avatargroup-1d900174.js +34 -0
  55. package/dist/esm/backtop.taro-99107c30.js +39 -62
  56. package/dist/esm/badge.taro-fe9171ec.js +40 -58
  57. package/dist/esm/barrage.taro-0e157b5e.js +61 -91
  58. package/dist/esm/bem-893ad28d.js +3 -6
  59. package/dist/esm/button.taro-4ce133b9.js +87 -98
  60. package/dist/esm/calendar.taro-4ed72058.js +38 -0
  61. package/dist/esm/calendaritem.taro-1ebe428d.js +571 -0
  62. package/dist/esm/card.taro-39055e82.js +32 -0
  63. package/dist/esm/cascader.taro-d8cb1c3e.js +397 -636
  64. package/dist/esm/cell.taro-9a04a92e.js +64 -0
  65. package/dist/esm/cellgroup.taro-e094471c.js +18 -27
  66. package/dist/esm/checkbox.taro-0bda9796.js +160 -232
  67. package/dist/esm/circleprogress.taro-47db537c.js +99 -120
  68. package/dist/esm/col.taro-b61c7cba.js +33 -50
  69. package/dist/esm/collapse.taro-af58206c.js +73 -86
  70. package/dist/esm/collapseitem-ce1849d2.js +75 -139
  71. package/dist/esm/configprovider-5eea4f5d.js +19 -0
  72. package/dist/esm/configprovider.taro-26882dd2.js +42 -0
  73. package/dist/esm/countdown.taro-9e40de9c.js +225 -0
  74. package/dist/esm/datepicker.taro-7220e495.js +270 -0
  75. package/dist/esm/dialog.taro-1c03960e.js +123 -0
  76. package/dist/esm/divider.taro-5236fe6a.js +27 -27
  77. package/dist/esm/drag.taro-82b6b27a.js +99 -138
  78. package/dist/esm/elevator.taro-d7d65470.js +185 -259
  79. package/dist/esm/ellipsis.taro-49b6db0c.js +232 -0
  80. package/dist/esm/empty.taro-7bd813f9.js +62 -0
  81. package/dist/esm/fixednav.taro-5ad15202.js +53 -0
  82. package/dist/esm/form.taro-71d32671.js +179 -0
  83. package/dist/esm/formitem.taro-3089489b.js +89 -0
  84. package/dist/esm/grid.taro-e6decfce.js +58 -0
  85. package/dist/esm/grid.taro.context-39636af9.js +4 -2
  86. package/dist/esm/griditem.taro-4cade72e.js +90 -0
  87. package/dist/esm/icon-8dc4de10.js +43 -51
  88. package/dist/esm/icon.taro-1d0d4fb7.js +43 -51
  89. package/dist/esm/image.taro-e6dc5867.js +64 -0
  90. package/dist/esm/imagepreview.taro-3400ea03.js +158 -205
  91. package/dist/esm/index.taro-a36f96fb.js +149 -210
  92. package/dist/esm/indicator.taro-183ea169.js +29 -43
  93. package/dist/esm/infiniteloading.taro-6c2a2e95.js +142 -0
  94. package/dist/esm/input.taro-fd566407.js +243 -0
  95. package/dist/esm/inputnumber.taro-dc39b853.js +129 -177
  96. package/dist/esm/layout.taro-358f014f.js +6 -9
  97. package/dist/esm/menu.taro-4abed328.js +89 -132
  98. package/dist/esm/menuitem.taro-6e8b27c3.js +130 -0
  99. package/dist/esm/navbar.taro-c931c078.js +69 -105
  100. package/dist/esm/noticebar.taro-69ea7673.js +450 -0
  101. package/dist/esm/notify.taro-308e5892.js +66 -97
  102. package/dist/esm/numberkeyboard.taro-194519e4.js +158 -0
  103. package/dist/esm/nutui-react.es.js +44 -44
  104. package/dist/esm/offsetContext-bfb02c25.js +3 -1
  105. package/dist/esm/overlay.taro-98367bc1.js +59 -74
  106. package/dist/esm/pagination.taro-bb490de9.js +124 -0
  107. package/dist/esm/picker.taro-2a8ded7c.js +420 -0
  108. package/dist/esm/popover.taro-46d813e8.js +132 -222
  109. package/dist/esm/popup.taro-cb777e09.js +125 -178
  110. package/dist/esm/price.taro-8801462e.js +75 -86
  111. package/dist/esm/progress.taro-623bc807.js +84 -118
  112. package/dist/esm/pulltorefresh.taro-cab7b51c.js +221 -0
  113. package/dist/esm/range.taro-5d6ff217.js +332 -0
  114. package/dist/esm/rate.taro-10197384.js +64 -111
  115. package/dist/esm/row.taro-37a895de.js +38 -42
  116. package/dist/esm/searchbar.taro-839dd622.js +148 -0
  117. package/dist/esm/shortpassword.taro-182d46f7.js +111 -0
  118. package/dist/esm/sidenavbar.taro-006cf38b.js +35 -0
  119. package/dist/esm/sidenavbaritem.taro-fee11d26.js +9 -22
  120. package/dist/esm/signature.taro-33632585.js +143 -0
  121. package/dist/esm/skeleton.taro-853ce460.js +51 -88
  122. package/dist/esm/step.taro-1c94e067.js +49 -78
  123. package/dist/esm/steps.taro-acf205a0.js +21 -30
  124. package/dist/esm/sticky.taro-d0553f48.js +13 -0
  125. package/dist/esm/subsidenavbar.taro-f46b4c73.js +58 -75
  126. package/dist/esm/swipe.taro-83bc248f.js +164 -254
  127. package/dist/esm/swiper.taro-852f6615.js +424 -505
  128. package/dist/esm/swiperitem-86a3578a.js +20 -28
  129. package/dist/esm/switch.taro-bae2dca0.js +43 -64
  130. package/dist/esm/tabbar.taro-86cece39.js +47 -57
  131. package/dist/esm/tabbaritem.taro-8dfb8055.js +51 -79
  132. package/dist/esm/table.taro-cb4dd2c3.js +92 -0
  133. package/dist/esm/tabpane.taro-91cd6cf4.js +17 -22
  134. package/dist/esm/tabs.taro-e71875fa.js +121 -165
  135. package/dist/esm/tag.taro-00fe554d.js +89 -0
  136. package/dist/esm/textarea.taro-42600f8c.js +74 -0
  137. package/dist/esm/timedetail.taro-c5f564fd.js +44 -0
  138. package/dist/esm/timepannel.taro-29f9dd86.js +22 -0
  139. package/dist/esm/timeselect.taro-3ecce65d.js +133 -0
  140. package/dist/esm/toast.taro-0804b6b4.js +99 -137
  141. package/dist/esm/trendarrow.taro-5a7153e4.js +63 -90
  142. package/dist/esm/types/src/packages/cell/cell.taro.d.ts +0 -1
  143. package/dist/esm/types/src/packages/noticebar/noticebar.d.ts +5 -4
  144. package/dist/esm/types/src/packages/noticebar/noticebar.taro.d.ts +5 -4
  145. package/dist/esm/types/src/packages/uploader/uploader.d.ts +1 -1
  146. package/dist/esm/types/src/packages/virtuallist/virtuallist.taro.d.ts +13 -2
  147. package/dist/esm/typings-1c5f2628.js +7 -6
  148. package/dist/esm/uploader.taro-f80d76d9.js +392 -0
  149. package/dist/esm/useClientRect-bf69d7b3.js +5 -25
  150. package/dist/esm/useTouch-a2ea68c6.js +63 -93
  151. package/dist/esm/video-8a3518c5.js +59 -83
  152. package/dist/esm/virtuallist.taro-e3345ced.js +215 -0
  153. package/dist/esm/watermark.taro-cd9db98a.js +114 -0
  154. package/dist/esm/zh-CN-dfc384d0.js +128 -133
  155. package/dist/locales/base.js +1 -1
  156. package/dist/locales/en-US.js +1 -1
  157. package/dist/locales/id-ID.js +1 -1
  158. package/dist/locales/zh-CN.js +1 -1
  159. package/dist/locales/zh-TW.js +1 -1
  160. package/dist/locales/zh-UG.js +1 -1
  161. package/dist/nutui.react.es.js +634 -5664
  162. package/dist/nutui.react.umd.js +634 -5664
  163. package/dist/packages/noticebar/noticebar.scss +17 -0
  164. package/dist/packages/radio/radio.scss +3 -1
  165. package/dist/packages/row/row.scss +2 -0
  166. package/dist/packages/searchbar/searchbar.scss +1 -1
  167. package/dist/packages/tag/tag.scss +13 -5
  168. package/dist/packages/virtuallist/virtuallist.scss +24 -0
  169. package/dist/style.css +1 -1
  170. package/dist/style.es.js +1 -1
  171. package/dist/styles/temp.scss +2340 -0
  172. package/dist/styles/theme-dark.scss +7 -0
  173. package/dist/styles/theme-default.scss +11 -0
  174. package/dist/styles/variables.scss +1945 -710
  175. package/dist/types/index.d.ts +16 -23
  176. package/package.json +9 -4
  177. package/dist/esm/address.taro-1e2aea24.js +0 -615
  178. package/dist/esm/audio.taro-fddcdfc0.js +0 -228
  179. package/dist/esm/avatargroup-f7f600ff.js +0 -42
  180. package/dist/esm/calendar.taro-72974415.js +0 -83
  181. package/dist/esm/calendaritem.taro-84e889eb.js +0 -580
  182. package/dist/esm/card.taro-a530dfb3.js +0 -61
  183. package/dist/esm/cell.taro-cf50c4f2.js +0 -109
  184. package/dist/esm/configprovider-c7d60e20.js +0 -18
  185. package/dist/esm/configprovider.taro-8bdb3a28.js +0 -50
  186. package/dist/esm/countdown.taro-d7dc8681.js +0 -246
  187. package/dist/esm/datepicker.taro-7199f521.js +0 -304
  188. package/dist/esm/dialog.taro-f54cfbf0.js +0 -187
  189. package/dist/esm/ellipsis.taro-c0de6ff4.js +0 -309
  190. package/dist/esm/empty.taro-dbc66496.js +0 -81
  191. package/dist/esm/fixednav.taro-9e759320.js +0 -97
  192. package/dist/esm/form.taro-880014b1.js +0 -181
  193. package/dist/esm/formitem.taro-3695f4a7.js +0 -136
  194. package/dist/esm/grid.taro-c2cc12d6.js +0 -81
  195. package/dist/esm/griditem.taro-892153cd.js +0 -122
  196. package/dist/esm/image.taro-c30973d5.js +0 -105
  197. package/dist/esm/infiniteloading.taro-b5ddf3cc.js +0 -188
  198. package/dist/esm/input.taro-104130c1.js +0 -361
  199. package/dist/esm/menuitem.taro-216e9f7d.js +0 -193
  200. package/dist/esm/noticebar.taro-94002898.js +0 -368
  201. package/dist/esm/numberkeyboard.taro-5e8f0ddf.js +0 -245
  202. package/dist/esm/pagination.taro-9925ffab.js +0 -169
  203. package/dist/esm/picker.taro-3b5cc054.js +0 -540
  204. package/dist/esm/pulltorefresh.taro-f26a20dd.js +0 -302
  205. package/dist/esm/range.taro-c41e9b90.js +0 -469
  206. package/dist/esm/searchbar.taro-01ed4ea4.js +0 -236
  207. package/dist/esm/shortpassword.taro-3a3bf412.js +0 -190
  208. package/dist/esm/sidenavbar.taro-06026f31.js +0 -66
  209. package/dist/esm/signature.taro-17648cac.js +0 -192
  210. package/dist/esm/sticky.taro-36013e97.js +0 -16
  211. package/dist/esm/table.taro-adda6622.js +0 -139
  212. package/dist/esm/tag.taro-bd900990.js +0 -104
  213. package/dist/esm/textarea.taro-83d5fe73.js +0 -102
  214. package/dist/esm/timedetail.taro-105f5380.js +0 -68
  215. package/dist/esm/timepannel.taro-c66c63dd.js +0 -30
  216. package/dist/esm/timeselect.taro-fc7ec6ee.js +0 -172
  217. package/dist/esm/uploader.taro-a1edf38f.js +0 -529
  218. package/dist/esm/virtuallist.taro-4add61c3.js +0 -315
  219. package/dist/esm/watermark.taro-323d1cf3.js +0 -132
@@ -0,0 +1,332 @@
1
+ import React__default, { useState, useRef, useEffect, useCallback } from 'react';
2
+ import { u as useTouch } from './useTouch-a2ea68c6.js';
3
+ import { g as getRectByTaro } from './useClientRect-bf69d7b3.js';
4
+ import { T as Toast } from './toast.taro-0804b6b4.js';
5
+ import { u as useConfig } from './configprovider.taro-26882dd2.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": "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": "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 };
@@ -1,119 +1,72 @@
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
1
  import React__default, { useState, useEffect } from 'react';
6
2
  import { c as cn } from './bem-893ad28d.js';
7
3
  import { I as Icon } from './icon-8dc4de10.js';
8
4
  import { C as ComponentDefaults } from './typings-1c5f2628.js';
9
- var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
10
- count: 5,
11
- modelValue: 0,
12
- minimizeValue: 0,
13
- iconSize: 18,
14
- activeColor: '',
15
- voidColor: '',
16
- checkedIcon: 'star-fill-n',
17
- uncheckedIcon: 'star-n',
18
- disabled: false,
19
- readonly: false,
20
- allowHalf: false,
21
- spacing: 14
22
- });
23
- var Rate = function Rate(props) {
24
- var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
25
- className = _defaultProps$props.className,
26
- style = _defaultProps$props.style,
27
- count = _defaultProps$props.count,
28
- modelValue = _defaultProps$props.modelValue,
29
- minimizeValue = _defaultProps$props.minimizeValue,
30
- iconSize = _defaultProps$props.iconSize,
31
- activeColor = _defaultProps$props.activeColor,
32
- voidColor = _defaultProps$props.voidColor,
33
- checkedIcon = _defaultProps$props.checkedIcon,
34
- uncheckedIcon = _defaultProps$props.uncheckedIcon,
35
- disabled = _defaultProps$props.disabled,
36
- readonly = _defaultProps$props.readonly,
37
- allowHalf = _defaultProps$props.allowHalf,
38
- spacing = _defaultProps$props.spacing,
39
- onChange = _defaultProps$props.onChange,
40
- iconClassPrefix = _defaultProps$props.iconClassPrefix,
41
- iconFontClassName = _defaultProps$props.iconFontClassName;
42
- var b = cn('rate');
43
- var bi = cn('rate-item');
44
- var _useState = useState([1, 2, 3, 4, 5]),
45
- _useState2 = _slicedToArray(_useState, 2),
46
- countArray = _useState2[0],
47
- setCountArray = _useState2[1];
48
- var _useState3 = useState(0),
49
- _useState4 = _slicedToArray(_useState3, 2),
50
- score = _useState4[0],
51
- setScore = _useState4[1];
52
- useEffect(function () {
53
- var tmp = [];
54
- for (var i = 1; i <= Number(count); i++) {
55
- tmp.push(i);
56
- }
57
- setCountArray(tmp);
58
- }, [count]);
59
- useEffect(function () {
60
- setScore(Math.max(Number(modelValue), Number(minimizeValue)));
61
- }, [modelValue]);
62
- var pxCheck = function pxCheck(value) {
63
- return Number.isNaN(Number(value)) ? String(value) : "".concat(value, "px");
64
- };
65
- var _onClick = function onClick(e, index) {
66
- e.preventDefault();
67
- e.stopPropagation();
68
- if (disabled || readonly) return;
69
- var value = 0;
70
- if (!(index === 1 && score === index)) {
71
- value = index;
72
- }
73
- value = Math.max(value, Number(minimizeValue));
74
- setScore(value);
75
- onChange && onChange(value);
76
- };
77
- var onHalfClick = function onHalfClick(event, n) {
78
- event.preventDefault();
79
- event.stopPropagation();
80
- var value = Math.max(Number(minimizeValue), n - 0.5);
81
- setScore(value);
82
- onChange && onChange(value);
83
- };
84
- return React__default.createElement("div", {
85
- className: "".concat(b(), " ").concat(className),
86
- style: style
87
- }, countArray.map(function (n) {
88
- return React__default.createElement("div", {
89
- className: bi(),
90
- key: n,
91
- onClick: function onClick(event) {
92
- return _onClick(event, n);
93
- },
94
- style: {
95
- marginRight: pxCheck(spacing)
96
- }
97
- }, React__default.createElement(Icon, {
98
- classPrefix: iconClassPrefix,
99
- fontClassName: iconFontClassName,
100
- size: iconSize,
101
- className: "".concat(bi('icon'), " ").concat(disabled || n > score ? bi('icon--disabled') : ''),
102
- name: n <= score ? checkedIcon : uncheckedIcon,
103
- color: n <= score ? activeColor : voidColor
104
- }), allowHalf && score > n - 1 && React__default.createElement(Icon, {
105
- classPrefix: iconClassPrefix,
106
- fontClassName: iconFontClassName,
107
- onClick: function onClick(event) {
108
- return onHalfClick(event, n);
109
- },
110
- className: "".concat(bi('icon'), " ").concat(bi('icon--half')),
111
- color: n <= score ? activeColor : voidColor,
112
- size: iconSize,
113
- name: checkedIcon
114
- }));
115
- }));
5
+
6
+ const defaultProps = {
7
+ ...ComponentDefaults,
8
+ count: 5,
9
+ modelValue: 0,
10
+ minimizeValue: 0,
11
+ iconSize: 18,
12
+ activeColor: '',
13
+ voidColor: '',
14
+ checkedIcon: 'star-fill-n',
15
+ uncheckedIcon: 'star-n',
16
+ disabled: false,
17
+ readonly: false,
18
+ allowHalf: false,
19
+ spacing: 14,
20
+ };
21
+ const Rate = (props) => {
22
+ const { className, style, count, modelValue, minimizeValue, iconSize, activeColor, voidColor, checkedIcon, uncheckedIcon, disabled, readonly, allowHalf, spacing, onChange, iconClassPrefix, iconFontClassName, } = {
23
+ ...defaultProps,
24
+ ...props,
25
+ };
26
+ const b = cn('rate');
27
+ const bi = cn('rate-item');
28
+ const [countArray, setCountArray] = useState([1, 2, 3, 4, 5]);
29
+ const [score, setScore] = useState(0);
30
+ useEffect(() => {
31
+ const tmp = [];
32
+ for (let i = 1; i <= Number(count); i++) {
33
+ tmp.push(i);
34
+ }
35
+ setCountArray(tmp);
36
+ }, [count]);
37
+ useEffect(() => {
38
+ setScore(Math.max(Number(modelValue), Number(minimizeValue)));
39
+ }, [modelValue]);
40
+ const pxCheck = (value) => {
41
+ return Number.isNaN(Number(value)) ? String(value) : `${value}px`;
42
+ };
43
+ const onClick = (e, index) => {
44
+ e.preventDefault();
45
+ e.stopPropagation();
46
+ if (disabled || readonly)
47
+ return;
48
+ let value = 0;
49
+ if (!(index === 1 && score === index)) {
50
+ value = index;
51
+ }
52
+ value = Math.max(value, Number(minimizeValue));
53
+ setScore(value);
54
+ onChange && onChange(value);
55
+ };
56
+ const onHalfClick = (event, n) => {
57
+ event.preventDefault();
58
+ event.stopPropagation();
59
+ const value = Math.max(Number(minimizeValue), n - 0.5);
60
+ setScore(value);
61
+ onChange && onChange(value);
62
+ };
63
+ return (React__default.createElement("div", { className: `${b()} ${className}`, style: style }, countArray.map((n) => {
64
+ return (React__default.createElement("div", { className: bi(), key: n, onClick: (event) => onClick(event, n), style: { marginRight: pxCheck(spacing) } },
65
+ React__default.createElement(Icon, { classPrefix: iconClassPrefix, fontClassName: iconFontClassName, size: iconSize, className: `${bi('icon')} ${disabled || n > score ? bi('icon--disabled') : ''}`, name: n <= score ? checkedIcon : uncheckedIcon, color: n <= score ? activeColor : voidColor }),
66
+ 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 }))));
67
+ })));
116
68
  };
117
69
  Rate.defaultProps = defaultProps;
118
70
  Rate.displayName = 'NutRate';
71
+
119
72
  export { Rate as R };
@@ -1,49 +1,45 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- 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; }
3
- 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; }
4
1
  import React__default from 'react';
5
2
  import { D as DataContext } from './UserContext-be8097d2.js';
6
- var defaultProps = {
7
- type: '',
8
- justify: 'start',
9
- align: 'flex-start',
10
- wrap: 'nowrap',
11
- gutter: '0'
3
+
4
+ const defaultProps = {
5
+ type: '',
6
+ justify: 'start',
7
+ align: 'flex-start',
8
+ wrap: 'nowrap',
9
+ gutter: '0',
12
10
  };
13
- var Row = function Row(props) {
14
- var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
15
- className = _defaultProps$props.className,
16
- _defaultProps$props$s = _defaultProps$props.style,
17
- style = _defaultProps$props$s === void 0 ? {} : _defaultProps$props$s,
18
- children = _defaultProps$props.children,
19
- type = _defaultProps$props.type,
20
- justify = _defaultProps$props.justify,
21
- align = _defaultProps$props.align,
22
- wrap = _defaultProps$props.wrap,
23
- gutter = _defaultProps$props.gutter,
24
- _onClick = _defaultProps$props.onClick;
25
- var prefixCls = 'nut-row';
26
- var getClass = function getClass(prefix, type) {
27
- var classType = type ? "nut-row-".concat(prefix, "-").concat(type) : '';
28
- var className = prefix ? classType : "nut-row-".concat(type);
29
- return className;
30
- };
31
- var getClasses = function getClasses() {
32
- return "\n ".concat(getClass('', type), "\n ").concat(getClass('justify', justify), "\n ").concat(getClass('align', align), "\n ").concat(getClass('flex', wrap), "\n ").concat(prefixCls, "\n ");
33
- };
34
- var parentRow = {
35
- gutter: gutter
36
- };
37
- return React__default.createElement(DataContext.Provider, {
38
- value: parentRow
39
- }, React__default.createElement('div', {
40
- className: "".concat(getClasses(), " ").concat(className),
41
- style: style,
42
- onClick: function onClick(e) {
43
- _onClick && _onClick(e, 'row');
44
- }
45
- }, children));
11
+ const Row = (props) => {
12
+ const { className, style = {}, children, type, justify, align, wrap, gutter, onClick, } = {
13
+ ...defaultProps,
14
+ ...props,
15
+ };
16
+ const prefixCls = 'nut-row';
17
+ const getClass = (prefix, type) => {
18
+ const classType = type ? `nut-row-${prefix}-${type}` : '';
19
+ const className = prefix ? classType : `nut-row-${type}`;
20
+ return className;
21
+ };
22
+ const getClasses = () => {
23
+ return `
24
+ ${getClass('', type)}
25
+ ${getClass('justify', justify)}
26
+ ${getClass('align', align)}
27
+ ${getClass('flex', wrap)}
28
+ ${prefixCls}
29
+ `;
30
+ };
31
+ const parentRow = {
32
+ gutter,
33
+ };
34
+ return (React__default.createElement(DataContext.Provider, { value: parentRow }, React__default.createElement('div', {
35
+ className: `${getClasses()} ${className}`,
36
+ style,
37
+ onClick: (e) => {
38
+ onClick && onClick(e, 'row');
39
+ },
40
+ }, children)));
46
41
  };
47
42
  Row.defaultProps = defaultProps;
48
43
  Row.displayName = 'NutRow';
44
+
49
45
  export { Row as R };