taro-ui 3.3.3 → 3.4.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 (312) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +85 -0
  3. package/dist/common/utils.d.ts +2 -1
  4. package/dist/common/utils.js +3 -0
  5. package/dist/common/utils.js.map +1 -1
  6. package/dist/components/accordion/index.d.ts +16 -13
  7. package/dist/components/accordion/index.js +77 -97
  8. package/dist/components/accordion/index.js.map +1 -1
  9. package/dist/components/action-sheet/body/index.d.ts +2 -4
  10. package/dist/components/action-sheet/body/index.js +8 -6
  11. package/dist/components/action-sheet/body/index.js.map +1 -1
  12. package/dist/components/action-sheet/body/item/index.d.ts +7 -7
  13. package/dist/components/action-sheet/body/item/index.js +14 -14
  14. package/dist/components/action-sheet/body/item/index.js.map +1 -1
  15. package/dist/components/action-sheet/footer/index.d.ts +7 -7
  16. package/dist/components/action-sheet/footer/index.js +14 -17
  17. package/dist/components/action-sheet/footer/index.js.map +1 -1
  18. package/dist/components/action-sheet/header/index.d.ts +2 -4
  19. package/dist/components/action-sheet/header/index.js +8 -9
  20. package/dist/components/action-sheet/header/index.js.map +1 -1
  21. package/dist/components/action-sheet/index.d.ts +12 -13
  22. package/dist/components/action-sheet/index.js +53 -57
  23. package/dist/components/action-sheet/index.js.map +1 -1
  24. package/dist/components/activity-indicator/index.d.ts +12 -6
  25. package/dist/components/activity-indicator/index.js +19 -22
  26. package/dist/components/activity-indicator/index.js.map +1 -1
  27. package/dist/components/avatar/index.d.ts +14 -8
  28. package/dist/components/avatar/index.js +36 -43
  29. package/dist/components/avatar/index.js.map +1 -1
  30. package/dist/components/badge/index.d.ts +11 -8
  31. package/dist/components/badge/index.js +18 -34
  32. package/dist/components/badge/index.js.map +1 -1
  33. package/dist/components/button/index.d.ts +29 -14
  34. package/dist/components/button/index.js +97 -112
  35. package/dist/components/button/index.js.map +1 -1
  36. package/dist/components/calendar/body/index.d.ts +3 -26
  37. package/dist/components/calendar/body/index.js +215 -235
  38. package/dist/components/calendar/body/index.js.map +1 -1
  39. package/dist/components/calendar/controller/index.d.ts +3 -5
  40. package/dist/components/calendar/controller/index.js +47 -43
  41. package/dist/components/calendar/controller/index.js.map +1 -1
  42. package/dist/components/calendar/index.d.ts +3 -20
  43. package/dist/components/calendar/index.js +219 -201
  44. package/dist/components/calendar/index.js.map +1 -1
  45. package/dist/components/calendar/ui/date-list/index.d.ts +2 -6
  46. package/dist/components/calendar/ui/date-list/index.js +36 -41
  47. package/dist/components/calendar/ui/date-list/index.js.map +1 -1
  48. package/dist/components/calendar/ui/day-list/index.d.ts +2 -4
  49. package/dist/components/calendar/ui/day-list/index.js +6 -5
  50. package/dist/components/calendar/ui/day-list/index.js.map +1 -1
  51. package/dist/components/card/index.d.ts +15 -7
  52. package/dist/components/card/index.js +42 -43
  53. package/dist/components/card/index.js.map +1 -1
  54. package/dist/components/checkbox/index.d.ts +11 -7
  55. package/dist/components/checkbox/index.js +30 -35
  56. package/dist/components/checkbox/index.js.map +1 -1
  57. package/dist/components/config-provider/context.d.ts +6 -0
  58. package/dist/components/config-provider/context.js +13 -0
  59. package/dist/components/config-provider/context.js.map +1 -0
  60. package/dist/components/config-provider/index.d.ts +7 -0
  61. package/dist/components/config-provider/index.js +15 -0
  62. package/dist/components/config-provider/index.js.map +1 -0
  63. package/dist/components/countdown/index.d.ts +19 -19
  64. package/dist/components/countdown/index.js +183 -118
  65. package/dist/components/countdown/index.js.map +1 -1
  66. package/dist/components/countdown/item/index.d.ts +8 -7
  67. package/dist/components/countdown/item/index.js +10 -13
  68. package/dist/components/countdown/item/index.js.map +1 -1
  69. package/dist/components/curtain/index.d.ts +11 -8
  70. package/dist/components/curtain/index.js +36 -45
  71. package/dist/components/curtain/index.js.map +1 -1
  72. package/dist/components/divider/index.d.ts +13 -6
  73. package/dist/components/divider/index.js +29 -38
  74. package/dist/components/divider/index.js.map +1 -1
  75. package/dist/components/drawer/index.d.ts +13 -15
  76. package/dist/components/drawer/index.js +100 -93
  77. package/dist/components/drawer/index.js.map +1 -1
  78. package/dist/components/fab/index.d.ts +8 -7
  79. package/dist/components/fab/index.js +16 -16
  80. package/dist/components/fab/index.js.map +1 -1
  81. package/dist/components/flex/index.d.ts +11 -5
  82. package/dist/components/flex/index.js +17 -18
  83. package/dist/components/flex/index.js.map +1 -1
  84. package/dist/components/flex/item/index.d.ts +11 -5
  85. package/dist/components/flex/item/index.js +17 -18
  86. package/dist/components/flex/item/index.js.map +1 -1
  87. package/dist/components/float-layout/index.d.ts +20 -12
  88. package/dist/components/float-layout/index.js +56 -72
  89. package/dist/components/float-layout/index.js.map +1 -1
  90. package/dist/components/form/index.d.ts +11 -8
  91. package/dist/components/form/index.js +28 -28
  92. package/dist/components/form/index.js.map +1 -1
  93. package/dist/components/grid/index.d.ts +22 -7
  94. package/dist/components/grid/index.js +61 -66
  95. package/dist/components/grid/index.js.map +1 -1
  96. package/dist/components/icon/index.d.ts +13 -7
  97. package/dist/components/icon/index.js +24 -34
  98. package/dist/components/icon/index.js.map +1 -1
  99. package/dist/components/image-picker/index.d.ts +19 -9
  100. package/dist/components/image-picker/index.js +83 -102
  101. package/dist/components/image-picker/index.js.map +1 -1
  102. package/dist/components/indexes/index.d.ts +16 -28
  103. package/dist/components/indexes/index.js +198 -209
  104. package/dist/components/indexes/index.js.map +1 -1
  105. package/dist/components/input/index.d.ts +37 -15
  106. package/dist/components/input/index.js +152 -161
  107. package/dist/components/input/index.js.map +1 -1
  108. package/dist/components/input-number/index.d.ts +20 -11
  109. package/dist/components/input-number/index.js +107 -126
  110. package/dist/components/input-number/index.js.map +1 -1
  111. package/dist/components/list/index.d.ts +7 -6
  112. package/dist/components/list/index.js +15 -15
  113. package/dist/components/list/index.js.map +1 -1
  114. package/dist/components/list/item/index.d.ts +27 -9
  115. package/dist/components/list/item/index.js +89 -117
  116. package/dist/components/list/item/index.js.map +1 -1
  117. package/dist/components/load-more/index.d.ts +15 -7
  118. package/dist/components/load-more/index.js +29 -50
  119. package/dist/components/load-more/index.js.map +1 -1
  120. package/dist/components/loading/index.d.ts +8 -7
  121. package/dist/components/loading/index.js +14 -20
  122. package/dist/components/loading/index.js.map +1 -1
  123. package/dist/components/message/index.d.ts +9 -14
  124. package/dist/components/message/index.js +45 -59
  125. package/dist/components/message/index.js.map +1 -1
  126. package/dist/components/modal/action/index.d.ts +7 -6
  127. package/dist/components/modal/action/index.js +15 -15
  128. package/dist/components/modal/action/index.js.map +1 -1
  129. package/dist/components/modal/content/index.d.ts +2 -4
  130. package/dist/components/modal/content/index.js +8 -6
  131. package/dist/components/modal/content/index.js.map +1 -1
  132. package/dist/components/modal/header/index.d.ts +2 -4
  133. package/dist/components/modal/header/index.js +8 -6
  134. package/dist/components/modal/header/index.js.map +1 -1
  135. package/dist/components/modal/index.d.ts +16 -14
  136. package/dist/components/modal/index.js +63 -77
  137. package/dist/components/modal/index.js.map +1 -1
  138. package/dist/components/nav-bar/index.d.ts +20 -10
  139. package/dist/components/nav-bar/index.js +146 -162
  140. package/dist/components/nav-bar/index.js.map +1 -1
  141. package/dist/components/noticebar/index.d.ts +17 -15
  142. package/dist/components/noticebar/index.js +115 -128
  143. package/dist/components/noticebar/index.js.map +1 -1
  144. package/dist/components/pagination/index.d.ts +13 -11
  145. package/dist/components/pagination/index.js +64 -120
  146. package/dist/components/pagination/index.js.map +1 -1
  147. package/dist/components/progress/index.d.ts +11 -5
  148. package/dist/components/progress/index.js +39 -36
  149. package/dist/components/progress/index.js.map +1 -1
  150. package/dist/components/radio/index.d.ts +11 -7
  151. package/dist/components/radio/index.js +29 -33
  152. package/dist/components/radio/index.js.map +1 -1
  153. package/dist/components/range/index.d.ts +19 -21
  154. package/dist/components/range/index.js +146 -153
  155. package/dist/components/range/index.js.map +1 -1
  156. package/dist/components/rate/index.d.ts +13 -7
  157. package/dist/components/rate/index.js +47 -62
  158. package/dist/components/rate/index.js.map +1 -1
  159. package/dist/components/search-bar/index.d.ts +23 -15
  160. package/dist/components/search-bar/index.js +120 -146
  161. package/dist/components/search-bar/index.js.map +1 -1
  162. package/dist/components/segmented-control/index.d.ts +14 -7
  163. package/dist/components/segmented-control/index.js +52 -66
  164. package/dist/components/segmented-control/index.js.map +1 -1
  165. package/dist/components/slider/index.d.ts +21 -12
  166. package/dist/components/slider/index.js +66 -90
  167. package/dist/components/slider/index.js.map +1 -1
  168. package/dist/components/steps/index.d.ts +11 -7
  169. package/dist/components/steps/index.js +43 -48
  170. package/dist/components/steps/index.js.map +1 -1
  171. package/dist/components/swipe-action/index.d.ts +12 -25
  172. package/dist/components/swipe-action/index.js +118 -115
  173. package/dist/components/swipe-action/index.js.map +1 -1
  174. package/dist/components/swipe-action/options/index.d.ts +2 -4
  175. package/dist/components/swipe-action/options/index.js +18 -17
  176. package/dist/components/swipe-action/options/index.js.map +1 -1
  177. package/dist/components/switch/index.d.ts +14 -7
  178. package/dist/components/switch/index.js +36 -41
  179. package/dist/components/switch/index.js.map +1 -1
  180. package/dist/components/tab-bar/index.d.ts +17 -7
  181. package/dist/components/tab-bar/index.js +108 -135
  182. package/dist/components/tab-bar/index.js.map +1 -1
  183. package/dist/components/tabs/index.d.ts +17 -23
  184. package/dist/components/tabs/index.js +185 -174
  185. package/dist/components/tabs/index.js.map +1 -1
  186. package/dist/components/tabs-pane/index.d.ts +11 -6
  187. package/dist/components/tabs-pane/index.js +26 -28
  188. package/dist/components/tabs-pane/index.js.map +1 -1
  189. package/dist/components/tag/index.d.ts +14 -7
  190. package/dist/components/tag/index.js +31 -40
  191. package/dist/components/tag/index.js.map +1 -1
  192. package/dist/components/textarea/index.d.ts +29 -11
  193. package/dist/components/textarea/index.js +72 -92
  194. package/dist/components/textarea/index.js.map +1 -1
  195. package/dist/components/timeline/index.d.ts +9 -6
  196. package/dist/components/timeline/index.js +50 -56
  197. package/dist/components/timeline/index.js.map +1 -1
  198. package/dist/components/toast/img.json +3 -6
  199. package/dist/components/toast/index.d.ts +16 -15
  200. package/dist/components/toast/index.js +85 -94
  201. package/dist/components/toast/index.js.map +1 -1
  202. package/dist/hooks/useComponentLocale.d.ts +2 -0
  203. package/dist/hooks/useComponentLocale.js +12 -0
  204. package/dist/hooks/useComponentLocale.js.map +1 -0
  205. package/dist/index.d.ts +3 -0
  206. package/dist/index.esm.js +4006 -4404
  207. package/dist/index.esm.js.map +1 -1
  208. package/dist/index.js +4032 -4434
  209. package/dist/index.js.map +1 -1
  210. package/dist/locale/en_US.d.ts +3 -0
  211. package/dist/locale/en_US.js +34 -0
  212. package/dist/locale/en_US.js.map +1 -0
  213. package/dist/locale/index.d.ts +4 -0
  214. package/dist/locale/index.js +10 -0
  215. package/dist/locale/index.js.map +1 -0
  216. package/dist/locale/types.d.ts +34 -0
  217. package/dist/locale/types.js +1 -0
  218. package/dist/locale/types.js.map +1 -0
  219. package/dist/locale/zh_CN.d.ts +3 -0
  220. package/dist/locale/zh_CN.js +34 -0
  221. package/dist/locale/zh_CN.js.map +1 -0
  222. package/dist/style/components/avatar.scss +1 -1
  223. package/dist/style/components/badge.scss +7 -2
  224. package/dist/style/components/calendar.scss +1 -1
  225. package/dist/style/components/countdown.scss +2 -1
  226. package/dist/style/components/flex.scss +1 -1
  227. package/dist/style/components/grid.scss +2 -2
  228. package/dist/style/components/icon.scss +302 -101
  229. package/dist/style/components/input.scss +2 -2
  230. package/dist/style/components/progress.scss +1 -1
  231. package/dist/style/components/search-bar.scss +1 -1
  232. package/dist/style/components/steps.scss +2 -2
  233. package/dist/style/components/tabs.scss +1 -1
  234. package/dist/style/components/tag.scss +1 -1
  235. package/dist/style/components/timeline.scss +1 -1
  236. package/dist/style/components/toast.scss +7 -3
  237. package/dist/style/index.css +176 -176
  238. package/dist/style/index.css.map +1 -1
  239. package/dist/style/mixins/libs/hairline.scss +4 -19
  240. package/dist/style/mixins/libs/shade.scss +3 -6
  241. package/dist/style/mixins/libs/tint.scss +4 -7
  242. package/dist/style/themes/purple.scss +15 -15
  243. package/dist/style/themes/red.scss +16 -13
  244. package/dist/style/variables/default.scss +69 -73
  245. package/package.json +5 -3
  246. package/rn/components/accordion/index.tsx +2 -9
  247. package/rn/components/action-sheet/body/index.tsx +1 -3
  248. package/rn/components/action-sheet/body/item/index.tsx +1 -3
  249. package/rn/components/action-sheet/footer/index.tsx +1 -3
  250. package/rn/components/action-sheet/header/index.tsx +1 -3
  251. package/rn/components/activity-indicator/index.tsx +1 -3
  252. package/rn/components/avatar/index.tsx +5 -5
  253. package/rn/components/calendar/controller/index.tsx +2 -7
  254. package/rn/components/card/index.tsx +4 -4
  255. package/rn/components/countdown/index.scss +5 -4
  256. package/rn/components/countdown/item/index.tsx +1 -3
  257. package/rn/components/curtain/index.tsx +5 -5
  258. package/rn/components/flex/index.scss +2 -2
  259. package/rn/components/flex/item/index.scss +2 -2
  260. package/rn/components/grid/index.tsx +15 -15
  261. package/rn/components/icon/index.tsx +4 -4
  262. package/rn/components/image-picker/index.tsx +7 -7
  263. package/rn/components/pagination/index.tsx +7 -7
  264. package/rn/components/progress/index.tsx +5 -5
  265. package/rn/components/radio/index.tsx +7 -7
  266. package/rn/components/rate/index.tsx +4 -4
  267. package/rn/components/segmented-control/index.tsx +8 -8
  268. package/rn/components/slider/index.tsx +9 -9
  269. package/rn/components/steps/index.tsx +8 -8
  270. package/rn/components/swipe-action/options/index.tsx +1 -3
  271. package/rn/components/switch/index.tsx +2 -9
  272. package/rn/components/toast/img.json +3 -6
  273. package/rn/components/toast/index.tsx +8 -8
  274. package/rn/style/components/accordion.scss +1 -1
  275. package/rn/style/components/action-sheet.scss +1 -1
  276. package/rn/style/components/avatar.scss +1 -1
  277. package/rn/style/components/badge.scss +8 -3
  278. package/rn/style/components/button.scss +1 -1
  279. package/rn/style/components/calendar.scss +1 -1
  280. package/rn/style/components/checkbox.scss +1 -1
  281. package/rn/style/components/curtain.scss +1 -1
  282. package/rn/style/components/fab.scss +1 -4
  283. package/rn/style/components/flex.scss +1 -1
  284. package/rn/style/components/grid.scss +2 -6
  285. package/rn/style/components/icon.scss +302 -101
  286. package/rn/style/components/index.scss +41 -41
  287. package/rn/style/components/input.scss +1 -1
  288. package/rn/style/components/list.scss +2 -4
  289. package/rn/style/components/loading.scss +4 -4
  290. package/rn/style/components/message.scss +1 -1
  291. package/rn/style/components/modal.scss +0 -2
  292. package/rn/style/components/nav-bar.scss +3 -3
  293. package/rn/style/components/noticebar.scss +0 -4
  294. package/rn/style/components/progress.scss +1 -1
  295. package/rn/style/components/radio.scss +2 -2
  296. package/rn/style/components/range.scss +1 -1
  297. package/rn/style/components/search-bar.scss +1 -1
  298. package/rn/style/components/segmented-control.scss +4 -1
  299. package/rn/style/components/slider.scss +0 -1
  300. package/rn/style/components/steps.scss +3 -3
  301. package/rn/style/components/switch.scss +0 -1
  302. package/rn/style/components/tabs.scss +2 -2
  303. package/rn/style/components/tag.scss +1 -1
  304. package/rn/style/components/timeline.scss +0 -2
  305. package/rn/style/components/toast.scss +5 -2
  306. package/rn/style/index.scss +1 -1
  307. package/rn/style/mixins/libs/hairline.scss +4 -22
  308. package/rn/style/mixins/libs/shade.scss +1 -4
  309. package/rn/style/mixins/libs/tint.scss +2 -5
  310. package/rn/style/themes/purple.scss +15 -15
  311. package/rn/style/themes/red.scss +16 -13
  312. package/rn/style/variables/default.scss +69 -73
@@ -3,7 +3,7 @@ import _toString from "lodash/toString";
3
3
  import PropTypes from "prop-types";
4
4
  import React from "react";
5
5
  import { Input, Text, View } from "@tarojs/components";
6
- import { pxTransform } from "../../common/utils";
6
+ import { noop, pxTransform } from "../../common/utils";
7
7
  function addNum(num1, num2) {
8
8
  let sq1, sq2;
9
9
  try {
@@ -27,66 +27,67 @@ function parseValue(num) {
27
27
  }
28
28
  return _toString(num);
29
29
  }
30
- class AtInputNumber extends React.Component {
31
- constructor() {
32
- super(...arguments);
33
- this.handleValue = (value) => {
34
- const { max = 100, min = 0 } = this.props;
35
- let resultValue = value === "" ? min : value;
36
- if (Number(resultValue) > max) {
37
- resultValue = max;
38
- this.handleError({
39
- type: "OVER",
40
- errorValue: resultValue
41
- });
42
- }
43
- if (Number(resultValue) < min) {
44
- resultValue = min;
45
- this.handleError({
46
- type: "LOW",
47
- errorValue: resultValue
48
- });
49
- }
50
- if (resultValue && !Number(resultValue)) {
51
- resultValue = parseFloat(String(resultValue)) || min;
52
- this.handleError({
53
- type: "OVER",
54
- errorValue: resultValue
55
- });
56
- }
57
- resultValue = parseValue(String(resultValue));
58
- return resultValue;
59
- };
60
- this.handleInput = (e) => {
61
- const { value } = e.target;
62
- const { disabled } = this.props;
63
- if (disabled) return "";
64
- const newValue = this.handleValue(value);
65
- this.props.onChange(Number(newValue), e);
66
- return newValue;
67
- };
68
- this.handleBlur = (event) => this.props.onBlur && this.props.onBlur(event);
69
- this.handleError = (errorValue) => {
70
- if (!this.props.onErrorInput) {
71
- return;
72
- }
73
- this.props.onErrorInput(errorValue);
74
- };
75
- }
76
- handleClick(clickType, e) {
77
- const { disabled, value, min = 0, max = 100, step = 1 } = this.props;
30
+ function AtInputNumber({
31
+ customStyle = {},
32
+ className = "",
33
+ disabled = false,
34
+ disabledInput = false,
35
+ type = "number",
36
+ width = 0,
37
+ min = 0,
38
+ max = 100,
39
+ step = 1,
40
+ size = "normal",
41
+ value,
42
+ onChange = noop,
43
+ onBlur,
44
+ onErrorInput
45
+ }) {
46
+ const handleError = (errorValue) => {
47
+ if (!onErrorInput) {
48
+ return;
49
+ }
50
+ onErrorInput(errorValue);
51
+ };
52
+ const handleValue = (val) => {
53
+ let resultValue = val === "" ? min : val;
54
+ if (Number(resultValue) > max) {
55
+ resultValue = max;
56
+ handleError({
57
+ type: "OVER",
58
+ errorValue: resultValue
59
+ });
60
+ }
61
+ if (Number(resultValue) < min) {
62
+ resultValue = min;
63
+ handleError({
64
+ type: "LOW",
65
+ errorValue: resultValue
66
+ });
67
+ }
68
+ if (resultValue && !Number(resultValue)) {
69
+ resultValue = parseFloat(String(resultValue)) || min;
70
+ handleError({
71
+ type: "OVER",
72
+ errorValue: resultValue
73
+ });
74
+ }
75
+ resultValue = parseValue(String(resultValue));
76
+ return resultValue;
77
+ };
78
+ const handleClick = (clickType, e) => {
78
79
  const lowThanMin = clickType === "minus" && Number(value) <= min;
79
80
  const overThanMax = clickType === "plus" && Number(value) >= max;
80
81
  if (lowThanMin || overThanMax || disabled) {
81
82
  const deltaValue2 = clickType === "minus" ? -step : step;
82
83
  const errorValue = addNum(Number(value), deltaValue2);
83
84
  if (disabled) {
84
- this.handleError({
85
+ handleError({
85
86
  type: "DISABLED",
86
87
  errorValue
87
88
  });
88
89
  } else {
89
- this.handleError({
90
+ handleError({
90
91
  type: lowThanMin ? "LOW" : "OVER",
91
92
  errorValue
92
93
  });
@@ -95,82 +96,61 @@ class AtInputNumber extends React.Component {
95
96
  }
96
97
  const deltaValue = clickType === "minus" ? -step : step;
97
98
  let newValue = addNum(Number(value), deltaValue);
98
- newValue = Number(this.handleValue(newValue));
99
- this.props.onChange(newValue, e);
100
- }
101
- render() {
102
- const {
103
- customStyle,
104
- className,
105
- width,
106
- disabled,
107
- value,
99
+ newValue = Number(handleValue(newValue));
100
+ onChange(newValue, e);
101
+ };
102
+ const handleInput = (e) => {
103
+ const { value: inputVal } = e.target;
104
+ if (disabled) return "";
105
+ const newValue = handleValue(inputVal);
106
+ onChange(Number(newValue), e);
107
+ return newValue;
108
+ };
109
+ const handleBlur = (event) => onBlur && onBlur(event);
110
+ const inputStyle = {
111
+ width: width ? `${pxTransform(width)}` : ""
112
+ };
113
+ const inputValue = typeof value !== "undefined" ? Number(handleValue(value)) : null;
114
+ const rootCls = classNames(
115
+ "at-input-number",
116
+ {
117
+ "at-input-number--lg": size === "large"
118
+ },
119
+ className
120
+ );
121
+ const minusBtnCls = classNames("at-input-number__btn", {
122
+ "at-input-number--disabled": inputValue !== null && inputValue <= min || disabled
123
+ });
124
+ const plusBtnCls = classNames("at-input-number__btn", {
125
+ "at-input-number--disabled": inputValue !== null && inputValue >= max || disabled
126
+ });
127
+ return /* @__PURE__ */ React.createElement(View, { className: rootCls, style: customStyle }, /* @__PURE__ */ React.createElement(
128
+ View,
129
+ {
130
+ className: minusBtnCls,
131
+ onClick: (e) => handleClick("minus", e)
132
+ },
133
+ /* @__PURE__ */ React.createElement(Text, { className: "at-icon at-icon-subtract at-input-number__btn-subtract" })
134
+ ), /* @__PURE__ */ React.createElement(
135
+ Input,
136
+ {
137
+ className: "at-input-number__input",
138
+ style: inputStyle,
108
139
  type,
109
- min = 0,
110
- max = 100,
111
- size,
112
- disabledInput
113
- } = this.props;
114
- const inputStyle = {
115
- width: width ? `${pxTransform(width)}` : ""
116
- };
117
- const inputValue = typeof value !== "undefined" ? Number(this.handleValue(value)) : null;
118
- const rootCls = classNames(
119
- "at-input-number",
120
- {
121
- "at-input-number--lg": size === "large"
122
- },
123
- className
124
- );
125
- const minusBtnCls = classNames("at-input-number__btn", {
126
- "at-input-number--disabled": inputValue !== null && inputValue <= min || disabled
127
- });
128
- const plusBtnCls = classNames("at-input-number__btn", {
129
- "at-input-number--disabled": inputValue !== null && inputValue >= max || disabled
130
- });
131
- return /* @__PURE__ */ React.createElement(View, { className: rootCls, style: customStyle }, /* @__PURE__ */ React.createElement(
132
- View,
133
- {
134
- className: minusBtnCls,
135
- onClick: this.handleClick.bind(this, "minus")
136
- },
137
- /* @__PURE__ */ React.createElement(Text, { className: "at-icon at-icon-subtract at-input-number__btn-subtract" })
138
- ), /* @__PURE__ */ React.createElement(
139
- Input,
140
- {
141
- className: "at-input-number__input",
142
- style: inputStyle,
143
- type,
144
- value: inputValue !== null ? String(inputValue) : "",
145
- disabled: disabledInput || disabled,
146
- onInput: this.handleInput,
147
- onBlur: this.handleBlur
148
- }
149
- ), /* @__PURE__ */ React.createElement(
150
- View,
151
- {
152
- className: plusBtnCls,
153
- onClick: this.handleClick.bind(this, "plus")
154
- },
155
- /* @__PURE__ */ React.createElement(Text, { className: "at-icon at-icon-add at-input-number__btn-add" })
156
- ));
157
- }
140
+ value: inputValue !== null ? String(inputValue) : "",
141
+ disabled: disabledInput || disabled,
142
+ onInput: handleInput,
143
+ onBlur: handleBlur
144
+ }
145
+ ), /* @__PURE__ */ React.createElement(
146
+ View,
147
+ {
148
+ className: plusBtnCls,
149
+ onClick: (e) => handleClick("plus", e)
150
+ },
151
+ /* @__PURE__ */ React.createElement(Text, { className: "at-icon at-icon-add at-input-number__btn-add" })
152
+ ));
158
153
  }
159
- AtInputNumber.defaultProps = {
160
- customStyle: {},
161
- className: "",
162
- disabled: false,
163
- disabledInput: false,
164
- type: "number",
165
- width: 0,
166
- min: 0,
167
- max: 100,
168
- step: 1,
169
- size: "normal",
170
- // eslint-disable-next-line @typescript-eslint/no-empty-function
171
- onChange: () => {
172
- }
173
- };
174
154
  AtInputNumber.propTypes = {
175
155
  customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
176
156
  className: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
@@ -187,7 +167,8 @@ AtInputNumber.propTypes = {
187
167
  onBlur: PropTypes.func,
188
168
  onErrorInput: PropTypes.func
189
169
  };
170
+ var input_number_default = AtInputNumber;
190
171
  export {
191
- AtInputNumber as default
172
+ input_number_default as default
192
173
  };
193
174
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/input-number/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport _toString from 'lodash/toString'\nimport PropTypes, { InferProps } from 'prop-types'\nimport React from 'react'\nimport { Input, Text, View } from '@tarojs/components'\nimport { CommonEvent, ITouchEvent } from '@tarojs/components/types/common'\nimport { AtInputNumberProps, InputError } from '../../../types/input-number'\nimport { pxTransform } from '../../common/utils'\n\n// TODO: Check all types\n\n// 实现两数相加并保留小数点后最短尾数\nfunction addNum(num1: number, num2: number): number {\n let sq1: number, sq2: number\n try {\n sq1 = _toString(num1).split('.')[1].length\n } catch (e) {\n sq1 = 0\n }\n try {\n sq2 = _toString(num2).split('.')[1].length\n } catch (e) {\n sq2 = 0\n }\n const m = Math.pow(10, Math.max(sq1, sq2))\n return (Math.round(num1 * m) + Math.round(num2 * m)) / m\n}\n\n// 格式化数字,处理01变成1,并且不处理1. 这种情况\nfunction parseValue(num: string): string {\n if (num === '') return '0'\n\n const numStr = _toString(num)\n if (numStr.indexOf('0') === 0 && numStr.indexOf('.') === -1) {\n // 处理01变成1,并且不处理1.\n return _toString(parseFloat(num))\n }\n return _toString(num)\n}\n\ntype ExtendEvent = {\n target: {\n value: string | number\n }\n}\n\nexport default class AtInputNumber extends React.Component<AtInputNumberProps> {\n public static defaultProps: AtInputNumberProps\n public static propTypes: InferProps<AtInputNumberProps>\n\n private handleClick(clickType: 'minus' | 'plus', e: CommonEvent): void {\n const { disabled, value, min = 0, max = 100, step = 1 } = this.props\n const lowThanMin = clickType === 'minus' && Number(value) <= min\n const overThanMax = clickType === 'plus' && Number(value) >= max\n if (lowThanMin || overThanMax || disabled) {\n const deltaValue = clickType === 'minus' ? -step : step\n const errorValue = addNum(Number(value), deltaValue)\n if (disabled) {\n this.handleError({\n type: 'DISABLED',\n errorValue\n })\n } else {\n this.handleError({\n type: lowThanMin ? 'LOW' : 'OVER',\n errorValue\n })\n }\n return\n }\n const deltaValue = clickType === 'minus' ? -step : step\n let newValue = addNum(Number(value), deltaValue)\n newValue = Number(this.handleValue(newValue))\n this.props.onChange(newValue, e)\n }\n\n private handleValue = (value: string | number): string => {\n const { max = 100, min = 0 } = this.props\n let resultValue = value === '' ? min : value\n // 此处不能使用 Math.max,会是字符串变数字,并丢失 .\n if (Number(resultValue) > max) {\n resultValue = max\n this.handleError({\n type: 'OVER',\n errorValue: resultValue\n })\n }\n if (Number(resultValue) < min) {\n resultValue = min\n this.handleError({\n type: 'LOW',\n errorValue: resultValue\n })\n }\n if (resultValue && !Number(resultValue)) {\n resultValue = parseFloat(String(resultValue)) || min\n\n this.handleError({\n type: 'OVER',\n errorValue: resultValue\n })\n }\n\n resultValue = parseValue(String(resultValue))\n return resultValue\n }\n\n private handleInput = (e: CommonEvent & ExtendEvent): string => {\n const { value } = e.target\n const { disabled } = this.props\n if (disabled) return ''\n\n const newValue = this.handleValue(value)\n this.props.onChange(Number(newValue), e)\n return newValue\n }\n\n private handleBlur = (event: ITouchEvent): void =>\n this.props.onBlur && this.props.onBlur(event)\n\n private handleError = (errorValue: InputError): void => {\n if (!this.props.onErrorInput) {\n return\n }\n this.props.onErrorInput(errorValue)\n }\n\n public render(): JSX.Element {\n const {\n customStyle,\n className,\n width,\n disabled,\n value,\n type,\n min = 0,\n max = 100,\n size,\n disabledInput\n } = this.props\n\n const inputStyle = {\n width: width ? `${pxTransform(width)}` : ''\n }\n const inputValue =\n typeof value !== 'undefined' ? Number(this.handleValue(value)) : null\n const rootCls = classNames(\n 'at-input-number',\n {\n 'at-input-number--lg': size === 'large'\n },\n className\n )\n const minusBtnCls = classNames('at-input-number__btn', {\n 'at-input-number--disabled':\n (inputValue !== null && inputValue <= min) || disabled\n })\n const plusBtnCls = classNames('at-input-number__btn', {\n 'at-input-number--disabled':\n (inputValue !== null && inputValue >= max) || disabled\n })\n\n return (\n <View className={rootCls} style={customStyle}>\n <View\n className={minusBtnCls}\n onClick={this.handleClick.bind(this, 'minus')}\n >\n <Text className='at-icon at-icon-subtract at-input-number__btn-subtract'></Text>\n </View>\n <Input\n className='at-input-number__input'\n style={inputStyle}\n type={type}\n value={inputValue !== null ? String(inputValue) : ''}\n disabled={disabledInput || disabled}\n onInput={this.handleInput}\n onBlur={this.handleBlur}\n />\n <View\n className={plusBtnCls}\n onClick={this.handleClick.bind(this, 'plus')}\n >\n <Text className='at-icon at-icon-add at-input-number__btn-add'></Text>\n </View>\n </View>\n )\n }\n}\n\nAtInputNumber.defaultProps = {\n customStyle: {},\n className: '',\n disabled: false,\n disabledInput: false,\n type: 'number',\n width: 0,\n min: 0,\n max: 100,\n step: 1,\n size: 'normal',\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n onChange: (): void => {}\n}\n\nAtInputNumber.propTypes = {\n customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n className: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),\n value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n type: PropTypes.oneOf(['number', 'digit']),\n disabled: PropTypes.bool,\n width: PropTypes.number,\n min: PropTypes.number,\n max: PropTypes.number,\n step: PropTypes.number,\n size: PropTypes.oneOf(['normal', 'large']),\n disabledInput: PropTypes.bool,\n onChange: PropTypes.func,\n onBlur: PropTypes.func,\n onErrorInput: PropTypes.func\n}\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,eAA+B;AACtC,OAAO,WAAW;AAClB,SAAS,OAAO,MAAM,YAAY;AAGlC,SAAS,mBAAmB;AAK5B,SAAS,OAAO,MAAc,MAAsB;AAClD,MAAI,KAAa;AACjB,MAAI;AACF,UAAM,UAAU,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE;AAAA,EACtC,SAAS,GAAG;AACV,UAAM;AAAA,EACR;AACA,MAAI;AACF,UAAM,UAAU,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE;AAAA,EACtC,SAAS,GAAG;AACV,UAAM;AAAA,EACR;AACA,QAAM,IAAI,KAAK,IAAI,IAAI,KAAK,IAAI,KAAK,GAAG,CAAC;AACzC,UAAQ,KAAK,MAAM,OAAO,CAAC,IAAI,KAAK,MAAM,OAAO,CAAC,KAAK;AACzD;AAGA,SAAS,WAAW,KAAqB;AACvC,MAAI,QAAQ,GAAI,QAAO;AAEvB,QAAM,SAAS,UAAU,GAAG;AAC5B,MAAI,OAAO,QAAQ,GAAG,MAAM,KAAK,OAAO,QAAQ,GAAG,MAAM,IAAI;AAE3D,WAAO,UAAU,WAAW,GAAG,CAAC;AAAA,EAClC;AACA,SAAO,UAAU,GAAG;AACtB;AAQA,MAAO,sBAAoC,MAAM,UAA8B;AAAA,EAA/E;AAAA;AA8BE,SAAQ,cAAc,CAAC,UAAmC;AACxD,YAAM,EAAE,MAAM,KAAK,MAAM,EAAE,IAAI,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version":3,"sources":["../../../src/components/input-number/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport _toString from 'lodash/toString'\nimport PropTypes from 'prop-types'\nimport React from 'react'\nimport { Input, Text, View } from '@tarojs/components'\nimport { CommonEvent, ITouchEvent } from '@tarojs/components/types/common'\nimport { AtInputNumberProps, InputError } from '../../../types/input-number'\nimport { noop, pxTransform } from '../../common/utils'\n\n// TODO: Check all types\n\n// 实现两数相加并保留小数点后最短尾数\nfunction addNum(num1: number, num2: number): number {\n let sq1: number, sq2: number\n try {\n sq1 = _toString(num1).split('.')[1].length\n } catch (e) {\n sq1 = 0\n }\n try {\n sq2 = _toString(num2).split('.')[1].length\n } catch (e) {\n sq2 = 0\n }\n const m = Math.pow(10, Math.max(sq1, sq2))\n return (Math.round(num1 * m) + Math.round(num2 * m)) / m\n}\n\n// 格式化数字,处理01变成1,并且不处理1. 这种情况\nfunction parseValue(num: string): string {\n if (num === '') return '0'\n\n const numStr = _toString(num)\n if (numStr.indexOf('0') === 0 && numStr.indexOf('.') === -1) {\n // 处理01变成1,并且不处理1.\n return _toString(parseFloat(num))\n }\n return _toString(num)\n}\n\ntype ExtendEvent = {\n target: {\n value: string | number\n }\n}\n\nfunction AtInputNumber({\n customStyle = {},\n className = '',\n disabled = false,\n disabledInput = false,\n type = 'number',\n width = 0,\n min = 0,\n max = 100,\n step = 1,\n size = 'normal',\n value,\n onChange = noop,\n onBlur,\n onErrorInput\n}: AtInputNumberProps): JSX.Element {\n const handleError = (errorValue: InputError): void => {\n if (!onErrorInput) {\n return\n }\n onErrorInput(errorValue)\n }\n\n const handleValue = (val: string | number): string => {\n let resultValue = val === '' ? min : val\n // 此处不能使用 Math.max,会是字符串变数字,并丢失 .\n if (Number(resultValue) > max) {\n resultValue = max\n handleError({\n type: 'OVER',\n errorValue: resultValue\n })\n }\n if (Number(resultValue) < min) {\n resultValue = min\n handleError({\n type: 'LOW',\n errorValue: resultValue\n })\n }\n if (resultValue && !Number(resultValue)) {\n resultValue = parseFloat(String(resultValue)) || min\n\n handleError({\n type: 'OVER',\n errorValue: resultValue\n })\n }\n\n resultValue = parseValue(String(resultValue))\n return resultValue\n }\n\n const handleClick = (clickType: 'minus' | 'plus', e: CommonEvent): void => {\n const lowThanMin = clickType === 'minus' && Number(value) <= min\n const overThanMax = clickType === 'plus' && Number(value) >= max\n if (lowThanMin || overThanMax || disabled) {\n const deltaValue = clickType === 'minus' ? -step : step\n const errorValue = addNum(Number(value), deltaValue)\n if (disabled) {\n handleError({\n type: 'DISABLED',\n errorValue\n })\n } else {\n handleError({\n type: lowThanMin ? 'LOW' : 'OVER',\n errorValue\n })\n }\n return\n }\n const deltaValue = clickType === 'minus' ? -step : step\n let newValue = addNum(Number(value), deltaValue)\n newValue = Number(handleValue(newValue))\n onChange(newValue, e)\n }\n\n const handleInput = (e: CommonEvent & ExtendEvent): string => {\n const { value: inputVal } = e.target\n if (disabled) return ''\n\n const newValue = handleValue(inputVal)\n onChange(Number(newValue), e)\n return newValue\n }\n\n const handleBlur = (event: ITouchEvent): void => onBlur && onBlur(event)\n\n const inputStyle = {\n width: width ? `${pxTransform(width)}` : ''\n }\n const inputValue =\n typeof value !== 'undefined' ? Number(handleValue(value)) : null\n const rootCls = classNames(\n 'at-input-number',\n {\n 'at-input-number--lg': size === 'large'\n },\n className\n )\n const minusBtnCls = classNames('at-input-number__btn', {\n 'at-input-number--disabled':\n (inputValue !== null && inputValue <= min) || disabled\n })\n const plusBtnCls = classNames('at-input-number__btn', {\n 'at-input-number--disabled':\n (inputValue !== null && inputValue >= max) || disabled\n })\n\n return (\n <View className={rootCls} style={customStyle}>\n <View\n className={minusBtnCls}\n onClick={(e: CommonEvent) => handleClick('minus', e)}\n >\n <Text className='at-icon at-icon-subtract at-input-number__btn-subtract'></Text>\n </View>\n <Input\n className='at-input-number__input'\n style={inputStyle}\n type={type}\n value={inputValue !== null ? String(inputValue) : ''}\n disabled={disabledInput || disabled}\n onInput={handleInput}\n onBlur={handleBlur}\n />\n <View\n className={plusBtnCls}\n onClick={(e: CommonEvent) => handleClick('plus', e)}\n >\n <Text className='at-icon at-icon-add at-input-number__btn-add'></Text>\n </View>\n </View>\n )\n}\n\nAtInputNumber.propTypes = {\n customStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),\n className: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),\n value: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),\n type: PropTypes.oneOf(['number', 'digit']),\n disabled: PropTypes.bool,\n width: PropTypes.number,\n min: PropTypes.number,\n max: PropTypes.number,\n step: PropTypes.number,\n size: PropTypes.oneOf(['normal', 'large']),\n disabledInput: PropTypes.bool,\n onChange: PropTypes.func,\n onBlur: PropTypes.func,\n onErrorInput: PropTypes.func\n}\n\nexport default AtInputNumber\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,OAAO,MAAM,YAAY;AAGlC,SAAS,MAAM,mBAAmB;AAKlC,SAAS,OAAO,MAAc,MAAsB;AAClD,MAAI,KAAa;AACjB,MAAI;AACF,UAAM,UAAU,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE;AAAA,EACtC,SAAS,GAAG;AACV,UAAM;AAAA,EACR;AACA,MAAI;AACF,UAAM,UAAU,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC,EAAE;AAAA,EACtC,SAAS,GAAG;AACV,UAAM;AAAA,EACR;AACA,QAAM,IAAI,KAAK,IAAI,IAAI,KAAK,IAAI,KAAK,GAAG,CAAC;AACzC,UAAQ,KAAK,MAAM,OAAO,CAAC,IAAI,KAAK,MAAM,OAAO,CAAC,KAAK;AACzD;AAGA,SAAS,WAAW,KAAqB;AACvC,MAAI,QAAQ,GAAI,QAAO;AAEvB,QAAM,SAAS,UAAU,GAAG;AAC5B,MAAI,OAAO,QAAQ,GAAG,MAAM,KAAK,OAAO,QAAQ,GAAG,MAAM,IAAI;AAE3D,WAAO,UA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AC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,OAAO;AAAA,MACP;AAAA,MACA,OAAO,eAAe,OAAO,OAAO,UAAU,IAAI;AAAA,MAClD,UAAU,iBAAiB;AAAA,MAC3B,SAAS;AAAA,MACT,QAAQ;AAAA;AAAA,EACV,GACA;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,MACX,SAAS,CAAC,MAAmB,YAAY,QAAQ,CAAC;AAAA;AAAA,IAElD,oCAAC,QAAK,WAAU,gDAA+C;AAAA,EACjE,CACF;AAEJ;AAEA,cAAc,YAAY;AAAA,EACxB,aAAa,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,EACrE,WAAW,UAAU,UAAU,CAAC,UAAU,OAAO,UAAU,MAAM,CAAC;AAAA,EAClE,OAAO,UAAU,UAAU,CAAC,UAAU,QAAQ,UAAU,MAAM,CAAC;AAAA,EAC/D,MAAM,UAAU,MAAM,CAAC,UAAU,OAAO,CAAC;AAAA,EACzC,UAAU,UAAU;AAAA,EACpB,OAAO,UAAU;AAAA,EACjB,KAAK,UAAU;AAAA,EACf,KAAK,UAAU;AAAA,EACf,MAAM,UAAU;AAAA,EAChB,MAAM,UAAU,MAAM,CAAC,UAAU,OAAO,CAAC;AAAA,EACzC,eAAe,UAAU;AAAA,EACzB,UAAU,UAAU;AAAA,EACpB,QAAQ,UAAU;AAAA,EAClB,cAAc,UAAU;AAC1B;AAEA,IAAO,uBAAQ;","names":["deltaValue"]}
@@ -1,8 +1,9 @@
1
- import { InferProps } from 'prop-types';
2
- import React from 'react';
1
+ import PropTypes from 'prop-types';
3
2
  import { AtListProps } from '../../../types/list';
4
- export default class AtList extends React.Component<AtListProps> {
5
- static defaultProps: AtListProps;
6
- static propTypes: InferProps<AtListProps>;
7
- render(): JSX.Element;
3
+ declare function AtList({ hasBorder, className, children }: AtListProps): JSX.Element;
4
+ declare namespace AtList {
5
+ var propTypes: {
6
+ hasBorder: PropTypes.Requireable<boolean>;
7
+ };
8
8
  }
9
+ export default AtList;
@@ -2,25 +2,25 @@ import classNames from "classnames";
2
2
  import PropTypes from "prop-types";
3
3
  import React from "react";
4
4
  import { View } from "@tarojs/components";
5
- class AtList extends React.Component {
6
- render() {
7
- const rootClass = classNames(
8
- "at-list",
9
- {
10
- "at-list--no-border": !this.props.hasBorder
11
- },
12
- this.props.className
13
- );
14
- return /* @__PURE__ */ React.createElement(View, { className: rootClass }, this.props.children);
15
- }
5
+ function AtList({
6
+ hasBorder = true,
7
+ className,
8
+ children
9
+ }) {
10
+ const rootClass = classNames(
11
+ "at-list",
12
+ {
13
+ "at-list--no-border": !hasBorder
14
+ },
15
+ className
16
+ );
17
+ return /* @__PURE__ */ React.createElement(View, { className: rootClass }, children);
16
18
  }
17
- AtList.defaultProps = {
18
- hasBorder: true
19
- };
20
19
  AtList.propTypes = {
21
20
  hasBorder: PropTypes.bool
22
21
  };
22
+ var list_default = AtList;
23
23
  export {
24
- AtList as default
24
+ list_default as default
25
25
  };
26
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/list/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes, { InferProps } from 'prop-types'\nimport React from 'react'\nimport { View } from '@tarojs/components'\nimport { AtListProps } from '../../../types/list'\n\nexport default class AtList extends React.Component<AtListProps> {\n public static defaultProps: AtListProps\n public static propTypes: InferProps<AtListProps>\n\n public render(): JSX.Element {\n const rootClass = classNames(\n 'at-list',\n {\n 'at-list--no-border': !this.props.hasBorder\n },\n this.props.className\n )\n\n return <View className={rootClass}>{this.props.children}</View>\n }\n}\n\nAtList.defaultProps = {\n hasBorder: true\n}\n\nAtList.propTypes = {\n hasBorder: PropTypes.bool\n}\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAA+B;AACtC,OAAO,WAAW;AAClB,SAAS,YAAY;AAGrB,MAAO,eAA6B,MAAM,UAAuB;AAAA,EAIxD,SAAsB;AAC3B,UAAM,YAAY;AAAA,MAChB;AAAA,MACA;AAAA,QACE,sBAAsB,CAAC,KAAK,MAAM;AAAA,MACpC;AAAA,MACA,KAAK,MAAM;AAAA,IACb;AAEA,WAAO,oCAAC,QAAK,WAAW,aAAY,KAAK,MAAM,QAAS;AAAA,EAC1D;AACF;AAEA,OAAO,eAAe;AAAA,EACpB,WAAW;AACb;AAEA,OAAO,YAAY;AAAA,EACjB,WAAW,UAAU;AACvB;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/list/index.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport PropTypes from 'prop-types'\nimport React from 'react'\nimport { View } from '@tarojs/components'\nimport { AtListProps } from '../../../types/list'\n\nfunction AtList({\n hasBorder = true,\n className,\n children\n}: AtListProps): JSX.Element {\n const rootClass = classNames(\n 'at-list',\n {\n 'at-list--no-border': !hasBorder\n },\n className\n )\n\n return <View className={rootClass}>{children}</View>\n}\n\nAtList.propTypes = {\n hasBorder: PropTypes.bool\n}\n\nexport default AtList\n"],"mappings":"AAAA,OAAO,gBAAgB;AACvB,OAAO,eAAe;AACtB,OAAO,WAAW;AAClB,SAAS,YAAY;AAGrB,SAAS,OAAO;AAAA,EACd,YAAY;AAAA,EACZ;AAAA,EACA;AACF,GAA6B;AAC3B,QAAM,YAAY;AAAA,IAChB;AAAA,IACA;AAAA,MACE,sBAAsB,CAAC;AAAA,IACzB;AAAA,IACA;AAAA,EACF;AAEA,SAAO,oCAAC,QAAK,WAAW,aAAY,QAAS;AAC/C;AAEA,OAAO,YAAY;AAAA,EACjB,WAAW,UAAU;AACvB;AAEA,IAAO,eAAQ;","names":[]}
@@ -1,11 +1,29 @@
1
- import { InferProps } from 'prop-types';
2
- import React from 'react';
1
+ import PropTypes from 'prop-types';
3
2
  import { AtListItemProps } from '../../../../types/list';
4
- export default class AtListItem extends React.Component<AtListItemProps> {
5
- static defaultProps: AtListItemProps;
6
- static propTypes: InferProps<AtListItemProps>;
7
- private handleClick;
8
- private handleSwitchClick;
9
- private handleSwitchChange;
10
- render(): JSX.Element;
3
+ declare function AtListItem({ note, disabled, title, thumb, isSwitch, hasBorder, switchColor, switchIsCheck, extraText, extraThumb, iconInfo, arrow, icon, className, onClick, onSwitchChange }: AtListItemProps): JSX.Element;
4
+ declare namespace AtListItem {
5
+ var propTypes: {
6
+ note: PropTypes.Requireable<NonNullable<string | PropTypes.ReactElementLike | null | undefined>>;
7
+ disabled: PropTypes.Requireable<boolean>;
8
+ title: PropTypes.Requireable<NonNullable<string | PropTypes.ReactElementLike | null | undefined>>;
9
+ thumb: PropTypes.Requireable<string>;
10
+ onClick: PropTypes.Requireable<(...args: any[]) => any>;
11
+ isSwitch: PropTypes.Requireable<boolean>;
12
+ hasBorder: PropTypes.Requireable<boolean>;
13
+ switchColor: PropTypes.Requireable<string>;
14
+ switchIsCheck: PropTypes.Requireable<boolean>;
15
+ extraText: PropTypes.Requireable<NonNullable<string | PropTypes.ReactElementLike | null | undefined>>;
16
+ extraThumb: PropTypes.Requireable<string>;
17
+ onSwitchChange: PropTypes.Requireable<(...args: any[]) => any>;
18
+ arrow: PropTypes.Requireable<string>;
19
+ iconInfo: PropTypes.Requireable<PropTypes.InferProps<{
20
+ size: PropTypes.Requireable<number>;
21
+ value: PropTypes.Requireable<string>;
22
+ color: PropTypes.Requireable<string>;
23
+ prefixClass: PropTypes.Requireable<string>;
24
+ customStyle: PropTypes.Requireable<NonNullable<string | object | null | undefined>>;
25
+ className: PropTypes.Requireable<NonNullable<string | any[] | null | undefined>>;
26
+ }>>;
27
+ };
11
28
  }
29
+ export default AtListItem;