@tuya-miniapp/smart-ui 1.3.1-beta-3 → 1.3.1-beta-5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (370) hide show
  1. package/dist/action-sheet/demo/index.d.ts +1 -0
  2. package/dist/action-sheet/demo/index.js +105 -0
  3. package/dist/action-sheet/index.js +2 -2
  4. package/dist/area/demo/index.d.ts +1 -0
  5. package/dist/area/demo/index.js +41 -0
  6. package/dist/area/index.js +4 -5
  7. package/dist/battery/demo/index.d.ts +1 -0
  8. package/dist/battery/demo/index.js +2 -0
  9. package/dist/battery/index.js +1 -3
  10. package/dist/bottom-sheet/demo/index.d.ts +1 -0
  11. package/dist/bottom-sheet/demo/index.js +24 -0
  12. package/dist/bottom-sheet/index.css +1 -1
  13. package/dist/bottom-sheet/index.js +3 -2
  14. package/dist/bottom-sheet/index.wxml +3 -1
  15. package/dist/bottom-sheet/index.wxss +1 -1
  16. package/dist/button/demo/index.d.ts +1 -0
  17. package/dist/button/demo/index.js +9 -0
  18. package/dist/button/index.css +1 -1
  19. package/dist/button/index.js +1 -1
  20. package/dist/button/index.wxss +1 -1
  21. package/dist/calendar/components/header/index.css +1 -1
  22. package/dist/calendar/components/header/index.js +1 -1
  23. package/dist/calendar/components/header/index.wxml +3 -3
  24. package/dist/calendar/components/header/index.wxss +1 -1
  25. package/dist/calendar/components/month/index.css +1 -1
  26. package/dist/calendar/components/month/index.js +3 -5
  27. package/dist/calendar/components/month/index.wxs +1 -4
  28. package/dist/calendar/components/month/index.wxss +1 -1
  29. package/dist/calendar/components/month-list/index.css +1 -1
  30. package/dist/calendar/components/month-list/index.js +4 -17
  31. package/dist/calendar/components/month-list/index.wxml +15 -13
  32. package/dist/calendar/components/month-list/index.wxss +1 -1
  33. package/dist/calendar/components/year-list/index.css +1 -1
  34. package/dist/calendar/components/year-list/index.js +3 -3
  35. package/dist/calendar/components/year-list/index.wxml +1 -1
  36. package/dist/calendar/components/year-list/index.wxss +1 -1
  37. package/dist/calendar/demo/index.d.ts +1 -0
  38. package/dist/calendar/demo/index.js +103 -0
  39. package/dist/calendar/index.js +9 -14
  40. package/dist/calendar/index.wxs +4 -7
  41. package/dist/calendar/utils.js +2 -4
  42. package/dist/cascader/demo/index.d.ts +1 -0
  43. package/dist/cascader/demo/index.js +191 -0
  44. package/dist/cascader/index.js +3 -3
  45. package/dist/cell/demo/index.d.ts +1 -0
  46. package/dist/cell/demo/index.js +14 -0
  47. package/dist/cell/index.js +1 -7
  48. package/dist/checkbox/demo/index.d.ts +1 -0
  49. package/dist/checkbox/demo/index.js +34 -0
  50. package/dist/checkbox/index.js +2 -2
  51. package/dist/checkbox-group/index.js +1 -1
  52. package/dist/circle/demo/index.d.ts +1 -0
  53. package/dist/circle/demo/index.js +19 -0
  54. package/dist/col/demo/index.d.ts +1 -0
  55. package/dist/col/demo/index.js +4 -0
  56. package/dist/collapse/demo/index.d.ts +1 -0
  57. package/dist/collapse/demo/index.js +36 -0
  58. package/dist/collapse/index.js +1 -1
  59. package/dist/collapse-item/animate.js +1 -1
  60. package/dist/common/component.js +1 -1
  61. package/dist/common/utils.js +3 -3
  62. package/dist/config-provider/demo/index.d.ts +1 -0
  63. package/dist/config-provider/demo/index.js +22 -0
  64. package/dist/count-down/demo/index.d.ts +1 -0
  65. package/dist/count-down/demo/index.js +33 -0
  66. package/dist/custom-keyboard/demo/index.d.ts +1 -0
  67. package/dist/custom-keyboard/demo/index.js +17 -0
  68. package/dist/custom-keyboard/index.js +1 -3
  69. package/dist/datetime-picker/demo/index.d.ts +1 -0
  70. package/dist/datetime-picker/demo/index.js +63 -0
  71. package/dist/datetime-picker/index.js +4 -5
  72. package/dist/dialog/demo/index.d.ts +1 -0
  73. package/dist/dialog/demo/index.js +134 -0
  74. package/dist/dialog/dialog.js +3 -5
  75. package/dist/dialog/index.js +1 -1
  76. package/dist/divider/demo/index.d.ts +1 -0
  77. package/dist/divider/demo/index.js +4 -0
  78. package/dist/dropdown-item/index.js +4 -4
  79. package/dist/dropdown-item/index.wxml +1 -7
  80. package/dist/dropdown-menu/demo/index.d.ts +1 -0
  81. package/dist/dropdown-menu/demo/index.js +47 -0
  82. package/dist/dropdown-menu/index.js +8 -10
  83. package/dist/empty/demo/index.d.ts +1 -0
  84. package/dist/empty/demo/index.js +13 -0
  85. package/dist/empty/index.css +1 -1
  86. package/dist/empty/index.wxs +1 -1
  87. package/dist/empty/index.wxss +1 -1
  88. package/dist/field/demo/index.d.ts +1 -0
  89. package/dist/field/demo/index.js +21 -0
  90. package/dist/goods-action/demo/index.d.ts +1 -0
  91. package/dist/goods-action/demo/index.js +12 -0
  92. package/dist/goods-action/index.css +1 -1
  93. package/dist/goods-action/index.js +1 -1
  94. package/dist/goods-action/index.wxss +1 -1
  95. package/dist/goods-action-button/index.css +1 -1
  96. package/dist/goods-action-button/index.wxss +1 -1
  97. package/dist/grid/demo/index.d.ts +1 -0
  98. package/dist/grid/demo/index.js +9 -0
  99. package/dist/grid/index.js +1 -1
  100. package/dist/grid-item/index.js +1 -1
  101. package/dist/icon/demo/index.d.ts +1 -0
  102. package/dist/icon/demo/index.js +26 -0
  103. package/dist/image/demo/index.d.ts +1 -0
  104. package/dist/image/demo/index.js +15 -0
  105. package/dist/index-anchor/index.js +1 -1
  106. package/dist/index-bar/demo/index.d.ts +1 -0
  107. package/dist/index-bar/demo/index.js +21 -0
  108. package/dist/index-bar/index.js +9 -16
  109. package/dist/loading/demo/index.d.ts +1 -0
  110. package/dist/loading/demo/index.js +4 -0
  111. package/dist/loading/index.js +25 -1
  112. package/dist/loading/index.wxml +2 -2
  113. package/dist/loading/index.wxs +6 -21
  114. package/dist/mixins/basic.js +2 -2
  115. package/dist/mixins/link.js +1 -2
  116. package/dist/mixins/page-scroll.js +1 -1
  117. package/dist/mixins/touch.js +1 -2
  118. package/dist/mixins/transition.js +1 -1
  119. package/dist/nav-bar/demo/index.d.ts +1 -0
  120. package/dist/nav-bar/demo/index.js +26 -0
  121. package/dist/nav-bar/index.css +1 -1
  122. package/dist/nav-bar/index.js +1 -1
  123. package/dist/nav-bar/index.wxml +1 -1
  124. package/dist/nav-bar/index.wxss +1 -1
  125. package/dist/normal-slider/demo/index.d.ts +1 -0
  126. package/dist/normal-slider/demo/index.js +19 -0
  127. package/dist/notice-bar/demo/index.d.ts +1 -0
  128. package/dist/notice-bar/demo/index.js +11 -0
  129. package/dist/notice-bar/index.js +3 -6
  130. package/dist/notice-bar/index.wxml +1 -5
  131. package/dist/notify/demo/index.d.ts +1 -0
  132. package/dist/notify/demo/index.js +45 -0
  133. package/dist/overlay/demo/index.d.ts +1 -0
  134. package/dist/overlay/demo/index.js +22 -0
  135. package/dist/picker/demo/index.d.ts +1 -0
  136. package/dist/picker/demo/index.js +76 -0
  137. package/dist/picker/index.css +1 -1
  138. package/dist/picker/index.js +2 -2
  139. package/dist/picker/index.wxml +1 -0
  140. package/dist/picker/index.wxss +1 -1
  141. package/dist/picker-column/index.js +3 -8
  142. package/dist/popup/demo/index.d.ts +1 -0
  143. package/dist/popup/demo/index.js +79 -0
  144. package/dist/progress/demo/index.d.ts +1 -0
  145. package/dist/progress/demo/index.js +4 -0
  146. package/dist/progress/index.js +1 -4
  147. package/dist/radio/demo/index.d.ts +1 -0
  148. package/dist/radio/demo/index.js +31 -0
  149. package/dist/radio/index.js +2 -2
  150. package/dist/radio-group/index.js +1 -1
  151. package/dist/rate/demo/index.d.ts +1 -0
  152. package/dist/rate/demo/index.js +25 -0
  153. package/dist/rate/index.js +2 -2
  154. package/dist/row/index.js +1 -1
  155. package/dist/search/demo/index.d.ts +1 -0
  156. package/dist/search/demo/index.js +43 -0
  157. package/dist/sidebar/demo/index.d.ts +1 -0
  158. package/dist/sidebar/demo/index.js +9 -0
  159. package/dist/skeleton/demo/index.d.ts +1 -0
  160. package/dist/skeleton/demo/index.js +11 -0
  161. package/dist/slider/demo/index.d.ts +1 -0
  162. package/dist/slider/demo/index.js +19 -0
  163. package/dist/slider/index.js +5 -7
  164. package/dist/stepper/demo/index.d.ts +1 -0
  165. package/dist/stepper/demo/index.js +19 -0
  166. package/dist/steps/demo/index.d.ts +1 -0
  167. package/dist/steps/demo/index.js +42 -0
  168. package/dist/sticky/demo/index.d.ts +1 -0
  169. package/dist/sticky/demo/index.js +26 -0
  170. package/dist/sticky/index.js +2 -2
  171. package/dist/swipe-cell/demo/index.d.ts +1 -0
  172. package/dist/swipe-cell/demo/index.js +45 -0
  173. package/dist/swipe-cell/index.js +3 -5
  174. package/dist/switch/demo/index.d.ts +1 -0
  175. package/dist/switch/demo/index.js +29 -0
  176. package/dist/switch/index.css +1 -1
  177. package/dist/switch/index.wxss +1 -1
  178. package/dist/tab/demo/index.d.ts +1 -0
  179. package/dist/tab/demo/index.js +55 -0
  180. package/dist/tabbar/demo/index.d.ts +1 -0
  181. package/dist/tabbar/demo/index.js +34 -0
  182. package/dist/tabbar/index.js +1 -1
  183. package/dist/tabs/index.js +7 -25
  184. package/dist/tag/demo/index.d.ts +1 -0
  185. package/dist/tag/demo/index.js +16 -0
  186. package/dist/tag/index.css +1 -1
  187. package/dist/tag/index.wxss +1 -1
  188. package/dist/toast/demo/index.d.ts +1 -0
  189. package/dist/toast/demo/index.js +67 -0
  190. package/dist/toast/toast.js +3 -5
  191. package/dist/transition/demo/index.d.ts +1 -0
  192. package/dist/transition/demo/index.js +67 -0
  193. package/dist/tree-select/demo/index.d.ts +1 -0
  194. package/dist/tree-select/demo/index.js +113 -0
  195. package/dist/tree-select/index.js +1 -1
  196. package/lib/action-sheet/demo/index.d.ts +1 -0
  197. package/lib/action-sheet/demo/index.js +119 -0
  198. package/lib/action-sheet/index.js +2 -2
  199. package/lib/area/demo/index.d.ts +1 -0
  200. package/lib/area/demo/index.js +47 -0
  201. package/lib/area/index.js +1 -2
  202. package/lib/battery/demo/index.d.ts +1 -0
  203. package/lib/battery/demo/index.js +4 -0
  204. package/lib/battery/index.js +1 -3
  205. package/lib/bottom-sheet/demo/index.d.ts +1 -0
  206. package/lib/bottom-sheet/demo/index.js +27 -0
  207. package/lib/bottom-sheet/index.css +1 -1
  208. package/lib/bottom-sheet/index.js +3 -2
  209. package/lib/bottom-sheet/index.wxml +3 -1
  210. package/lib/bottom-sheet/index.wxss +1 -1
  211. package/lib/button/demo/index.d.ts +1 -0
  212. package/lib/button/demo/index.js +14 -0
  213. package/lib/button/index.css +1 -1
  214. package/lib/button/index.wxss +1 -1
  215. package/lib/calendar/components/header/index.css +1 -1
  216. package/lib/calendar/components/header/index.wxml +3 -3
  217. package/lib/calendar/components/header/index.wxss +1 -1
  218. package/lib/calendar/components/month/index.css +1 -1
  219. package/lib/calendar/components/month/index.js +2 -6
  220. package/lib/calendar/components/month/index.wxs +1 -4
  221. package/lib/calendar/components/month/index.wxss +1 -1
  222. package/lib/calendar/components/month-list/index.css +1 -1
  223. package/lib/calendar/components/month-list/index.js +3 -16
  224. package/lib/calendar/components/month-list/index.wxml +15 -13
  225. package/lib/calendar/components/month-list/index.wxss +1 -1
  226. package/lib/calendar/components/year-list/index.css +1 -1
  227. package/lib/calendar/components/year-list/index.js +1 -1
  228. package/lib/calendar/components/year-list/index.wxml +1 -1
  229. package/lib/calendar/components/year-list/index.wxss +1 -1
  230. package/lib/calendar/demo/index.d.ts +1 -0
  231. package/lib/calendar/demo/index.js +105 -0
  232. package/lib/calendar/index.js +7 -14
  233. package/lib/calendar/index.wxs +4 -7
  234. package/lib/calendar/utils.js +1 -3
  235. package/lib/cascader/demo/index.d.ts +1 -0
  236. package/lib/cascader/demo/index.js +197 -0
  237. package/lib/cell/demo/index.d.ts +1 -0
  238. package/lib/cell/demo/index.js +39 -0
  239. package/lib/cell/index.js +1 -7
  240. package/lib/checkbox/demo/index.d.ts +1 -0
  241. package/lib/checkbox/demo/index.js +38 -0
  242. package/lib/checkbox/index.js +2 -2
  243. package/lib/circle/demo/index.d.ts +1 -0
  244. package/lib/circle/demo/index.js +21 -0
  245. package/lib/col/demo/index.d.ts +1 -0
  246. package/lib/col/demo/index.js +6 -0
  247. package/lib/collapse/demo/index.d.ts +1 -0
  248. package/lib/collapse/demo/index.js +42 -0
  249. package/lib/config-provider/demo/index.d.ts +1 -0
  250. package/lib/config-provider/demo/index.js +24 -0
  251. package/lib/count-down/demo/index.d.ts +1 -0
  252. package/lib/count-down/demo/index.js +38 -0
  253. package/lib/custom-keyboard/demo/index.d.ts +1 -0
  254. package/lib/custom-keyboard/demo/index.js +19 -0
  255. package/lib/custom-keyboard/index.js +1 -3
  256. package/lib/datetime-picker/demo/index.d.ts +1 -0
  257. package/lib/datetime-picker/demo/index.js +68 -0
  258. package/lib/datetime-picker/index.js +4 -3
  259. package/lib/dialog/demo/index.d.ts +1 -0
  260. package/lib/dialog/demo/index.js +144 -0
  261. package/lib/dialog/dialog.js +1 -3
  262. package/lib/divider/demo/index.d.ts +1 -0
  263. package/lib/divider/demo/index.js +6 -0
  264. package/lib/dropdown-item/index.js +2 -2
  265. package/lib/dropdown-item/index.wxml +1 -7
  266. package/lib/dropdown-menu/demo/index.d.ts +1 -0
  267. package/lib/dropdown-menu/demo/index.js +52 -0
  268. package/lib/dropdown-menu/index.js +2 -4
  269. package/lib/empty/demo/index.d.ts +1 -0
  270. package/lib/empty/demo/index.js +15 -0
  271. package/lib/empty/index.css +1 -1
  272. package/lib/empty/index.wxs +1 -1
  273. package/lib/empty/index.wxss +1 -1
  274. package/lib/field/demo/index.d.ts +1 -0
  275. package/lib/field/demo/index.js +23 -0
  276. package/lib/goods-action/demo/index.d.ts +1 -0
  277. package/lib/goods-action/demo/index.js +17 -0
  278. package/lib/goods-action/index.css +1 -1
  279. package/lib/goods-action/index.wxss +1 -1
  280. package/lib/goods-action-button/index.css +1 -1
  281. package/lib/goods-action-button/index.wxss +1 -1
  282. package/lib/grid/demo/index.d.ts +1 -0
  283. package/lib/grid/demo/index.js +11 -0
  284. package/lib/icon/demo/index.d.ts +1 -0
  285. package/lib/icon/demo/index.js +54 -0
  286. package/lib/image/demo/index.d.ts +1 -0
  287. package/lib/image/demo/index.js +17 -0
  288. package/lib/index-bar/demo/index.d.ts +1 -0
  289. package/lib/index-bar/demo/index.js +23 -0
  290. package/lib/index-bar/index.js +3 -10
  291. package/lib/loading/demo/index.d.ts +1 -0
  292. package/lib/loading/demo/index.js +6 -0
  293. package/lib/loading/index.js +27 -1
  294. package/lib/loading/index.wxml +2 -2
  295. package/lib/loading/index.wxs +6 -21
  296. package/lib/mixins/link.js +1 -2
  297. package/lib/mixins/touch.js +1 -2
  298. package/lib/nav-bar/demo/index.d.ts +1 -0
  299. package/lib/nav-bar/demo/index.js +31 -0
  300. package/lib/nav-bar/index.css +1 -1
  301. package/lib/nav-bar/index.wxml +1 -1
  302. package/lib/nav-bar/index.wxss +1 -1
  303. package/lib/normal-slider/demo/index.d.ts +1 -0
  304. package/lib/normal-slider/demo/index.js +21 -0
  305. package/lib/notice-bar/demo/index.d.ts +1 -0
  306. package/lib/notice-bar/demo/index.js +16 -0
  307. package/lib/notice-bar/index.js +2 -5
  308. package/lib/notice-bar/index.wxml +1 -5
  309. package/lib/notify/demo/index.d.ts +1 -0
  310. package/lib/notify/demo/index.js +50 -0
  311. package/lib/overlay/demo/index.d.ts +1 -0
  312. package/lib/overlay/demo/index.js +24 -0
  313. package/lib/picker/demo/index.d.ts +1 -0
  314. package/lib/picker/demo/index.js +82 -0
  315. package/lib/picker/index.css +1 -1
  316. package/lib/picker/index.js +1 -3
  317. package/lib/picker/index.wxml +1 -0
  318. package/lib/picker/index.wxss +1 -1
  319. package/lib/picker-column/index.js +2 -7
  320. package/lib/popup/demo/index.d.ts +1 -0
  321. package/lib/popup/demo/index.js +85 -0
  322. package/lib/progress/demo/index.d.ts +1 -0
  323. package/lib/progress/demo/index.js +6 -0
  324. package/lib/progress/index.js +1 -4
  325. package/lib/radio/demo/index.d.ts +1 -0
  326. package/lib/radio/demo/index.js +34 -0
  327. package/lib/radio/index.js +2 -2
  328. package/lib/rate/demo/index.d.ts +1 -0
  329. package/lib/rate/demo/index.js +30 -0
  330. package/lib/search/demo/index.d.ts +1 -0
  331. package/lib/search/demo/index.js +48 -0
  332. package/lib/sidebar/demo/index.d.ts +1 -0
  333. package/lib/sidebar/demo/index.js +14 -0
  334. package/lib/skeleton/demo/index.d.ts +1 -0
  335. package/lib/skeleton/demo/index.js +14 -0
  336. package/lib/slider/demo/index.d.ts +1 -0
  337. package/lib/slider/demo/index.js +21 -0
  338. package/lib/slider/index.js +1 -3
  339. package/lib/stepper/demo/index.d.ts +1 -0
  340. package/lib/stepper/demo/index.js +25 -0
  341. package/lib/steps/demo/index.d.ts +1 -0
  342. package/lib/steps/demo/index.js +47 -0
  343. package/lib/sticky/demo/index.d.ts +1 -0
  344. package/lib/sticky/demo/index.js +30 -0
  345. package/lib/sticky/index.js +3 -1
  346. package/lib/swipe-cell/demo/index.d.ts +1 -0
  347. package/lib/swipe-cell/demo/index.js +50 -0
  348. package/lib/swipe-cell/index.js +1 -3
  349. package/lib/switch/demo/index.d.ts +1 -0
  350. package/lib/switch/demo/index.js +37 -0
  351. package/lib/switch/index.css +1 -1
  352. package/lib/switch/index.wxss +1 -1
  353. package/lib/tab/demo/index.d.ts +1 -0
  354. package/lib/tab/demo/index.js +57 -0
  355. package/lib/tabbar/demo/index.d.ts +1 -0
  356. package/lib/tabbar/demo/index.js +41 -0
  357. package/lib/tabs/index.js +6 -24
  358. package/lib/tag/demo/index.d.ts +1 -0
  359. package/lib/tag/demo/index.js +19 -0
  360. package/lib/tag/index.css +1 -1
  361. package/lib/tag/index.wxss +1 -1
  362. package/lib/toast/demo/index.d.ts +1 -0
  363. package/lib/toast/demo/index.js +74 -0
  364. package/lib/toast/toast.js +1 -3
  365. package/lib/transition/demo/index.d.ts +1 -0
  366. package/lib/transition/demo/index.js +71 -0
  367. package/lib/tree-select/demo/index.d.ts +1 -0
  368. package/lib/tree-select/demo/index.js +130 -0
  369. package/lib/tree-select/index.js +2 -2
  370. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ import { SmartComponent } from '../../common/component';
2
+ SmartComponent({
3
+ data: {
4
+ container: () => { },
5
+ scrollTop: 0,
6
+ offsetTop: 0,
7
+ },
8
+ mounted() {
9
+ this.setData({
10
+ container: () => this.createSelectorQuery().select('#container'),
11
+ });
12
+ },
13
+ methods: {
14
+ onScroll(event) {
15
+ this.createSelectorQuery()
16
+ .select('#scroller')
17
+ .boundingClientRect((res) => {
18
+ this.setData({
19
+ scrollTop: event.detail.scrollTop,
20
+ offsetTop: res.top,
21
+ });
22
+ })
23
+ .exec();
24
+ },
25
+ },
26
+ });
@@ -79,7 +79,7 @@ SmartComponent({
79
79
  .catch(() => { });
80
80
  return;
81
81
  }
82
- getRect(this, ROOT_ELEMENT).then((root) => {
82
+ getRect(this, ROOT_ELEMENT).then(root => {
83
83
  if (!isDef(root) || (!root.width && !root.height)) {
84
84
  return;
85
85
  }
@@ -114,7 +114,7 @@ SmartComponent({
114
114
  if (!nodesRef) {
115
115
  return Promise.reject(new Error('not found container'));
116
116
  }
117
- return new Promise((resolve) => nodesRef.boundingClientRect(resolve).exec());
117
+ return new Promise(resolve => nodesRef.boundingClientRect(resolve).exec());
118
118
  },
119
119
  },
120
120
  });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
1
+ import { SmartComponent } from '../../common/component';
2
+ import Dialog from '../../dialog/dialog';
3
+ import Toast from '../../toast/toast';
4
+ SmartComponent({
5
+ methods: {
6
+ onClose(event) {
7
+ const { position, instance } = event.detail;
8
+ switch (position) {
9
+ case 'left':
10
+ case 'cell':
11
+ instance.close();
12
+ break;
13
+ case 'right':
14
+ Dialog.confirm({
15
+ context: this,
16
+ message: I18n.t('areYouSureYouWantToDelete'),
17
+ })
18
+ .then(() => {
19
+ instance.close();
20
+ })
21
+ .catch(() => {
22
+ console.log('cancel');
23
+ });
24
+ break;
25
+ }
26
+ },
27
+ onOpen(event) {
28
+ const { position, name } = event.detail;
29
+ switch (position) {
30
+ case 'left':
31
+ Toast({
32
+ context: this,
33
+ message: `${name}${position}${I18n.t('partialOpenEventTriggered')}`,
34
+ });
35
+ break;
36
+ case 'right':
37
+ Toast({
38
+ context: this,
39
+ message: `${name}${position}${I18n.t('partialDisplayOpenEventTriggered')}`,
40
+ });
41
+ break;
42
+ }
43
+ },
44
+ },
45
+ });
@@ -40,7 +40,7 @@ SmartComponent({
40
40
  ARRAY.push(this);
41
41
  },
42
42
  destroyed() {
43
- ARRAY = ARRAY.filter((item) => item !== this);
43
+ ARRAY = ARRAY.filter(item => item !== this);
44
44
  },
45
45
  methods: {
46
46
  open(position) {
@@ -58,9 +58,7 @@ SmartComponent({
58
58
  swipeMove(offset = 0) {
59
59
  this.offset = range(offset, -this.data.rightWidth, this.data.leftWidth);
60
60
  const transform = `translate3d(${this.offset}px, 0, 0)`;
61
- const transition = this.dragging
62
- ? 'none'
63
- : 'transform .6s cubic-bezier(0.18, 0.89, 0.32, 1)';
61
+ const transition = this.dragging ? 'none' : 'transform .6s cubic-bezier(0.18, 0.89, 0.32, 1)';
64
62
  this.setData({
65
63
  wrapperStyle: `
66
64
  -webkit-transform: ${transform};
@@ -101,7 +99,7 @@ SmartComponent({
101
99
  return;
102
100
  }
103
101
  this.dragging = true;
104
- ARRAY.filter((item) => item !== this && item.offset !== 0).forEach((item) => item.close());
102
+ ARRAY.filter(item => item !== this && item.offset !== 0).forEach(item => item.close());
105
103
  this.setData({ catchMove: true });
106
104
  this.swipeMove(this.startOffset + this.deltaX);
107
105
  },
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,29 @@
1
+ import { SmartComponent } from '../../common/component';
2
+ import Dialog from '../../dialog/dialog';
3
+ SmartComponent({
4
+ data: {
5
+ checked: true,
6
+ checked2: true,
7
+ },
8
+ methods: {
9
+ onChange({ detail }) {
10
+ this.setData({ checked: detail });
11
+ },
12
+ onChange2({ detail }) {
13
+ Dialog.confirm({
14
+ context: this,
15
+ title: I18n.t('prompt'),
16
+ message: I18n.t('doYouWantToToggleTheSwitch'),
17
+ }).then(() => {
18
+ this.setData({ checked2: detail });
19
+ });
20
+ },
21
+ onClick() {
22
+ Dialog.confirm({
23
+ context: this,
24
+ title: I18n.t('hint'),
25
+ message: I18n.t('bubbleEvent'),
26
+ });
27
+ },
28
+ },
29
+ });
@@ -1 +1 @@
1
- @import '../common/index.css';.smart-switch{background-color:var(--switch-background-color,var(--app-B4-N6,rgba(0,0,0,.2)));border:var(--switch-border,1px solid rgba(0,0,0,.1));border-radius:var(--switch-node-size,1em);box-sizing:initial;display:inline-block;height:var(--switch-height,1em);position:relative;transition:background-color var(--switch-transition-duration,.3s);width:var(--switch-width,1.667em)}.smart-switch__node{background-color:var(--switch-node-background-color,#fff);border-radius:100%;box-shadow:var(--switch-node-box-shadow,0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05));height:var(--switch-node-size,1em);left:0;position:absolute;top:0;transition:var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);width:var(--switch-node-size,1em);z-index:var(--switch-node-z-index,1)}.smart-switch__loading{left:50%;position:absolute!important;top:50%;transform:translate(-50%,-50%)}.smart-switch--on{background-color:var(--switch-on-background-color,#1989fa)}.smart-switch--on .smart-switch__node{transform:translateX(calc(var(--switch-width, 1.667em) - var(--switch-node-size, 1em)))}.smart-switch--disabled{opacity:var(--switch-disabled-opacity,.4)}
1
+ @import '../common/index.css';.smart-switch{background-color:var(--switch-background-color,var(--app-B4-N6,rgba(0,0,0,.2)));border:var(--switch-border,1px solid rgba(0,0,0,.1));border-color:transparent;border-radius:var(--switch-node-size,1em);box-sizing:initial;display:inline-block;height:var(--switch-height,1em);position:relative;transition:background-color var(--switch-transition-duration,.3s);width:var(--switch-width,1.667em)}.smart-switch__node{background-color:var(--switch-node-background-color,#fff);border-radius:100%;box-shadow:var(--switch-node-box-shadow,0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05));height:var(--switch-node-size,1em);left:0;position:absolute;top:0;transition:var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);width:var(--switch-node-size,1em);z-index:var(--switch-node-z-index,1)}.smart-switch__loading{left:50%;position:absolute!important;top:50%;transform:translate(-50%,-50%)}.smart-switch--on{background-color:var(--switch-on-background-color,#1989fa)}.smart-switch--on .smart-switch__node{transform:translateX(calc(var(--switch-width, 1.667em) - var(--switch-node-size, 1em)))}.smart-switch--disabled{opacity:var(--switch-disabled-opacity,.4)}
@@ -1 +1 @@
1
- @import '../common/index.wxss';.smart-switch{background-color:var(--switch-background-color,var(--app-B4-N6,rgba(0,0,0,.2)));border:var(--switch-border,1px solid rgba(0,0,0,.1));border-radius:var(--switch-node-size,1em);box-sizing:initial;display:inline-block;height:var(--switch-height,1em);position:relative;transition:background-color var(--switch-transition-duration,.3s);width:var(--switch-width,1.667em)}.smart-switch__node{background-color:var(--switch-node-background-color,#fff);border-radius:100%;box-shadow:var(--switch-node-box-shadow,0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05));height:var(--switch-node-size,1em);left:0;position:absolute;top:0;transition:var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);width:var(--switch-node-size,1em);z-index:var(--switch-node-z-index,1)}.smart-switch__loading{left:50%;position:absolute!important;top:50%;transform:translate(-50%,-50%)}.smart-switch--on{background-color:var(--switch-on-background-color,#1989fa)}.smart-switch--on .smart-switch__node{transform:translateX(calc(var(--switch-width, 1.667em) - var(--switch-node-size, 1em)))}.smart-switch--disabled{opacity:var(--switch-disabled-opacity,.4)}
1
+ @import '../common/index.wxss';.smart-switch{background-color:var(--switch-background-color,var(--app-B4-N6,rgba(0,0,0,.2)));border:var(--switch-border,1px solid rgba(0,0,0,.1));border-color:transparent;border-radius:var(--switch-node-size,1em);box-sizing:initial;display:inline-block;height:var(--switch-height,1em);position:relative;transition:background-color var(--switch-transition-duration,.3s);width:var(--switch-width,1.667em)}.smart-switch__node{background-color:var(--switch-node-background-color,#fff);border-radius:100%;box-shadow:var(--switch-node-box-shadow,0 3px 1px 0 rgba(0,0,0,.05),0 2px 2px 0 rgba(0,0,0,.1),0 3px 3px 0 rgba(0,0,0,.05));height:var(--switch-node-size,1em);left:0;position:absolute;top:0;transition:var(--switch-transition-duration,.3s) cubic-bezier(.3,1.05,.4,1.05);width:var(--switch-node-size,1em);z-index:var(--switch-node-z-index,1)}.smart-switch__loading{left:50%;position:absolute!important;top:50%;transform:translate(-50%,-50%)}.smart-switch--on{background-color:var(--switch-on-background-color,#1989fa)}.smart-switch--on .smart-switch__node{transform:translateX(calc(var(--switch-width, 1.667em) - var(--switch-node-size, 1em)))}.smart-switch--disabled{opacity:var(--switch-disabled-opacity,.4)}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,55 @@
1
+ import { SmartComponent } from '../../common/component';
2
+ SmartComponent({
3
+ data: {
4
+ tabs2: [1, 2],
5
+ tabs3: [1, 2, 3],
6
+ tabs4: [1, 2, 3, 4],
7
+ tabs6: [1, 2, 3, 4, 5, 6],
8
+ tabsWithName: [
9
+ { name: 'a', index: 1 },
10
+ { name: 'b', index: 2 },
11
+ { name: 'c', index: 3 },
12
+ ],
13
+ },
14
+ methods: {
15
+ onClickDisabled(event) {
16
+ wx.showToast({
17
+ title: `${I18n.t('label')} ${event.detail.index + 1} ${I18n.t('hasBeenDisabled')}`,
18
+ icon: 'none',
19
+ });
20
+ },
21
+ onChange(event) {
22
+ wx.showToast({
23
+ title: `${I18n.t('switchToTab')} ${event.detail.index + 1}`,
24
+ icon: 'none',
25
+ });
26
+ },
27
+ onClickNavRight() {
28
+ wx.showToast({
29
+ title: `${I18n.t('click')} right nav`,
30
+ icon: 'none',
31
+ });
32
+ },
33
+ onClick(event) {
34
+ wx.showToast({
35
+ title: `${I18n.t('clickTag')} ${event.detail.index + 1}`,
36
+ icon: 'none',
37
+ });
38
+ },
39
+ onBeforeChange(event) {
40
+ const { callback, title } = event.detail;
41
+ wx.showModal({
42
+ title: I18n.t('asynchronousSwitching'),
43
+ content: `I18n.t('areYouSureYouWantToSwitchTo') ${title} tab?`,
44
+ success: (res) => {
45
+ if (res.confirm) {
46
+ callback(true);
47
+ }
48
+ else if (res.cancel) {
49
+ callback(false);
50
+ }
51
+ },
52
+ });
53
+ },
54
+ },
55
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ import Tornado from '@tuya-miniapp/icons/dist/svg/Tornado';
2
+ import Timer from '@tuya-miniapp/icons/dist/svg/Timer';
3
+ import TorSnownado from '@tuya-miniapp/icons/dist/svg/Snow';
4
+ import Connect from '@tuya-miniapp/icons/dist/svg/Connect';
5
+ import { SmartComponent } from '../../common/component';
6
+ SmartComponent({
7
+ data: {
8
+ active: 0,
9
+ active2: 'home',
10
+ active3: 0,
11
+ active4: 0,
12
+ active5: 0,
13
+ active6: 0,
14
+ icon: {
15
+ normal: '',
16
+ active: 'https://static1.tuyacn.com/static/tuya-miniapp-doc/_next/static/images/logo-small.png',
17
+ },
18
+ defaultIcon1: Tornado,
19
+ defaultIcon2: Timer,
20
+ defaultIcon3: TorSnownado,
21
+ defaultIcon4: Connect,
22
+ },
23
+ methods: {
24
+ onChange(event) {
25
+ const { key } = event.currentTarget.dataset;
26
+ this.setData({ [key]: event.detail });
27
+ },
28
+ handleChange(event) {
29
+ const { key } = event.currentTarget.dataset;
30
+ this.setData({ [key]: event.detail });
31
+ wx.showToast({ title: `${I18n.t('clickTheTab')} ${event.detail + 1}`, icon: 'none' });
32
+ },
33
+ },
34
+ });
@@ -57,7 +57,7 @@ SmartComponent({
57
57
  return;
58
58
  }
59
59
  wx.nextTick(() => {
60
- getRect(this, '.smart-tabbar').then((res) => {
60
+ getRect(this, '.smart-tabbar').then(res => {
61
61
  this.setData({ height: res.height });
62
62
  });
63
63
  });
@@ -5,13 +5,7 @@ import { isDef } from '../common/validator';
5
5
  import { useChildren } from '../common/relation';
6
6
  SmartComponent({
7
7
  mixins: [touch],
8
- classes: [
9
- 'nav-class',
10
- 'tab-class',
11
- 'tab-active-class',
12
- 'line-class',
13
- 'wrap-class',
14
- ],
8
+ classes: ['nav-class', 'tab-class', 'tab-active-class', 'line-class', 'wrap-class'],
15
9
  relation: useChildren('tab', function () {
16
10
  this.updateTabs();
17
11
  }),
@@ -146,9 +140,7 @@ SmartComponent({
146
140
  },
147
141
  setCurrentIndex(currentIndex) {
148
142
  const { data, children = [] } = this;
149
- if (!isDef(currentIndex) ||
150
- currentIndex >= children.length ||
151
- currentIndex < 0) {
143
+ if (!isDef(currentIndex) || currentIndex >= children.length || currentIndex < 0) {
152
144
  return;
153
145
  }
154
146
  groupSetData(this, () => {
@@ -186,10 +178,7 @@ SmartComponent({
186
178
  },
187
179
  resize() {
188
180
  const { currentIndex, ellipsis, skipTransition, type } = this.data;
189
- Promise.all([
190
- getAllRect(this, '.smart-tab'),
191
- getRect(this, '.smart-tabs__line'),
192
- ]).then(([rects = [], lineRect]) => {
181
+ Promise.all([getAllRect(this, '.smart-tab'), getRect(this, '.smart-tabs__line')]).then(([rects = [], lineRect]) => {
193
182
  const rect = rects[currentIndex];
194
183
  if (rect == null) {
195
184
  return;
@@ -199,8 +188,7 @@ SmartComponent({
199
188
  .slice(0, currentIndex)
200
189
  .reduce((prev, curr) => prev + curr.width, 0);
201
190
  if (type === 'line') {
202
- lineOffsetLeft +=
203
- (rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8);
191
+ lineOffsetLeft += (rect.width - lineRect.width) / 2 + (ellipsis ? 0 : 8);
204
192
  }
205
193
  else if (type === 'card') {
206
194
  lineOffsetLeft += 2;
@@ -221,10 +209,7 @@ SmartComponent({
221
209
  if (!scrollable) {
222
210
  return;
223
211
  }
224
- Promise.all([
225
- getAllRect(this, '.smart-tab'),
226
- getRect(this, '.smart-tabs__nav'),
227
- ]).then(([tabRects, navRect]) => {
212
+ Promise.all([getAllRect(this, '.smart-tab'), getRect(this, '.smart-tabs__nav')]).then(([tabRects, navRect]) => {
228
213
  const tabRect = tabRects[currentIndex];
229
214
  const offsetLeft = tabRects
230
215
  .slice(0, currentIndex)
@@ -272,10 +257,7 @@ SmartComponent({
272
257
  const step = direction > 0 ? -1 : 1;
273
258
  for (let i = step; currentIndex + i < tabs.length && currentIndex + i >= 0; i += step) {
274
259
  const index = currentIndex + i;
275
- if (index >= 0 &&
276
- index < tabs.length &&
277
- tabs[index] &&
278
- !tabs[index].disabled) {
260
+ if (index >= 0 && index < tabs.length && tabs[index] && !tabs[index].disabled) {
279
261
  return index;
280
262
  }
281
263
  }
@@ -287,7 +269,7 @@ SmartComponent({
287
269
  return Promise.resolve();
288
270
  }
289
271
  return new Promise((resolve, reject) => {
290
- this.$emit('before-change', Object.assign(Object.assign({}, this.getChildData(index)), { callback: (status) => (status ? resolve() : reject()) }));
272
+ this.$emit('before-change', Object.assign(Object.assign({}, this.getChildData(index)), { callback: status => (status ? resolve() : reject()) }));
291
273
  });
292
274
  },
293
275
  getChildData(index, child) {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import { SmartComponent } from '../../common/component';
2
+ SmartComponent({
3
+ data: {
4
+ show: {
5
+ success: true,
6
+ primary: true,
7
+ },
8
+ },
9
+ methods: {
10
+ onClose(event) {
11
+ this.setData({
12
+ [`show.${event.target.id}`]: false,
13
+ });
14
+ },
15
+ },
16
+ });
@@ -1 +1 @@
1
- @import '../common/index.css';.smart-tag{align-items:center;border-radius:var(--tag-border-radius,4px);color:var(--tag-text-color,#fff);display:inline-flex;font-size:var(--tag-font-size,12px);line-height:var(--tag-line-height,17px);padding:var(--tag-padding,2px 8px);position:relative}.smart-tag--default{background-color:var(--tag-default-color,#969799)}.smart-tag--default.smart-tag--plain{color:var(--tag-default-color,#969799)}.smart-tag--danger{background-color:var(--tag-danger-color,#ee0a24)}.smart-tag--danger.smart-tag--plain{color:var(--tag-danger-color,#ee0a24)}.smart-tag--primary{background-color:var(--tag-primary-color,#1989fa)}.smart-tag--primary.smart-tag--plain{color:var(--tag-primary-color,#1989fa)}.smart-tag--success{background-color:var(--tag-success-color,#07c160)}.smart-tag--success.smart-tag--plain{color:var(--tag-success-color,#07c160)}.smart-tag--warning{background-color:var(--tag-warning-color,#ff976a)}.smart-tag--warning.smart-tag--plain{color:var(--tag-warning-color,#ff976a)}.smart-tag--plain{background-color:var(--tag-plain-background-color,#fff)}.smart-tag--plain:before{border:1px solid;border-radius:inherit;bottom:0;content:"";left:0;pointer-events:none;position:absolute;right:0;top:0}.smart-tag--medium{font-size:var(--tag-medium-font-size,14px);line-height:var(--tag-medium-line-height,20px)}.smart-tag--large{font-size:var(--tag-large-font-size,16px);line-height:var(--tag-large-line-height,22px)}.smart-tag--mark{border-radius:0 var(--tag-round-border-radius,var(--tag-round-border-radius,999px)) var(--tag-round-border-radius,var(--tag-round-border-radius,999px)) 0}.smart-tag--mark:after{content:"";display:block;width:2px}.smart-tag--round{border-radius:var(--tag-round-border-radius,999px)}.smart-tag__close{margin-left:2px;min-width:1em}
1
+ @import '../common/index.css';.smart-tag{align-items:center;border-radius:var(--tag-border-radius,4px);color:var(--tag-text-color,#fff);display:inline-flex;font-size:var(--tag-font-size,12px);line-height:var(--tag-line-height,17px);padding:var(--tag-padding,2px 8px);position:relative}.smart-tag--default{background-color:var(--tag-default-color,#969799)}.smart-tag--default.smart-tag--plain{color:var(--tag-default-color,#969799)}.smart-tag--danger{background-color:var(--tag-danger-color,#ee0a24)}.smart-tag--danger.smart-tag--plain{color:var(--tag-danger-color,#ee0a24)}.smart-tag--primary{background-color:var(--tag-primary-color,#1989fa)}.smart-tag--primary.smart-tag--plain{color:var(--tag-primary-color,#1989fa)}.smart-tag--success{background-color:var(--tag-success-color,#07c160)}.smart-tag--success.smart-tag--plain{color:var(--tag-success-color,#07c160)}.smart-tag--warning{background-color:var(--tag-warning-color,#ff976a)}.smart-tag--warning.smart-tag--plain{color:var(--tag-warning-color,#ff976a)}.smart-tag--plain{background-color:var(--tag-plain-background-color,transparent)}.smart-tag--plain:before{border:1px solid;border-radius:inherit;bottom:0;content:"";left:0;pointer-events:none;position:absolute;right:0;top:0}.smart-tag--medium{font-size:var(--tag-medium-font-size,14px);line-height:var(--tag-medium-line-height,20px)}.smart-tag--large{font-size:var(--tag-large-font-size,16px);line-height:var(--tag-large-line-height,22px)}.smart-tag--mark{border-radius:0 var(--tag-round-border-radius,var(--tag-round-border-radius,999px)) var(--tag-round-border-radius,var(--tag-round-border-radius,999px)) 0}.smart-tag--mark:after{content:"";display:block;width:2px}.smart-tag--round{border-radius:var(--tag-round-border-radius,999px)}.smart-tag__close{margin-left:2px;min-width:1em}
@@ -1 +1 @@
1
- @import '../common/index.wxss';.smart-tag{align-items:center;border-radius:var(--tag-border-radius,4px);color:var(--tag-text-color,#fff);display:inline-flex;font-size:var(--tag-font-size,12px);line-height:var(--tag-line-height,17px);padding:var(--tag-padding,2px 8px);position:relative}.smart-tag--default{background-color:var(--tag-default-color,#969799)}.smart-tag--default.smart-tag--plain{color:var(--tag-default-color,#969799)}.smart-tag--danger{background-color:var(--tag-danger-color,#ee0a24)}.smart-tag--danger.smart-tag--plain{color:var(--tag-danger-color,#ee0a24)}.smart-tag--primary{background-color:var(--tag-primary-color,#1989fa)}.smart-tag--primary.smart-tag--plain{color:var(--tag-primary-color,#1989fa)}.smart-tag--success{background-color:var(--tag-success-color,#07c160)}.smart-tag--success.smart-tag--plain{color:var(--tag-success-color,#07c160)}.smart-tag--warning{background-color:var(--tag-warning-color,#ff976a)}.smart-tag--warning.smart-tag--plain{color:var(--tag-warning-color,#ff976a)}.smart-tag--plain{background-color:var(--tag-plain-background-color,#fff)}.smart-tag--plain:before{border:1px solid;border-radius:inherit;bottom:0;content:"";left:0;pointer-events:none;position:absolute;right:0;top:0}.smart-tag--medium{font-size:var(--tag-medium-font-size,14px);line-height:var(--tag-medium-line-height,20px)}.smart-tag--large{font-size:var(--tag-large-font-size,16px);line-height:var(--tag-large-line-height,22px)}.smart-tag--mark{border-radius:0 var(--tag-round-border-radius,var(--tag-round-border-radius,999px)) var(--tag-round-border-radius,var(--tag-round-border-radius,999px)) 0}.smart-tag--mark:after{content:"";display:block;width:2px}.smart-tag--round{border-radius:var(--tag-round-border-radius,999px)}.smart-tag__close{margin-left:2px;min-width:1em}
1
+ @import '../common/index.wxss';.smart-tag{align-items:center;border-radius:var(--tag-border-radius,4px);color:var(--tag-text-color,#fff);display:inline-flex;font-size:var(--tag-font-size,12px);line-height:var(--tag-line-height,17px);padding:var(--tag-padding,2px 8px);position:relative}.smart-tag--default{background-color:var(--tag-default-color,#969799)}.smart-tag--default.smart-tag--plain{color:var(--tag-default-color,#969799)}.smart-tag--danger{background-color:var(--tag-danger-color,#ee0a24)}.smart-tag--danger.smart-tag--plain{color:var(--tag-danger-color,#ee0a24)}.smart-tag--primary{background-color:var(--tag-primary-color,#1989fa)}.smart-tag--primary.smart-tag--plain{color:var(--tag-primary-color,#1989fa)}.smart-tag--success{background-color:var(--tag-success-color,#07c160)}.smart-tag--success.smart-tag--plain{color:var(--tag-success-color,#07c160)}.smart-tag--warning{background-color:var(--tag-warning-color,#ff976a)}.smart-tag--warning.smart-tag--plain{color:var(--tag-warning-color,#ff976a)}.smart-tag--plain{background-color:var(--tag-plain-background-color,transparent)}.smart-tag--plain:before{border:1px solid;border-radius:inherit;bottom:0;content:"";left:0;pointer-events:none;position:absolute;right:0;top:0}.smart-tag--medium{font-size:var(--tag-medium-font-size,14px);line-height:var(--tag-medium-line-height,20px)}.smart-tag--large{font-size:var(--tag-large-font-size,16px);line-height:var(--tag-large-line-height,22px)}.smart-tag--mark{border-radius:0 var(--tag-round-border-radius,var(--tag-round-border-radius,999px)) var(--tag-round-border-radius,var(--tag-round-border-radius,999px)) 0}.smart-tag--mark:after{content:"";display:block;width:2px}.smart-tag--round{border-radius:var(--tag-round-border-radius,999px)}.smart-tag__close{margin-left:2px;min-width:1em}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,67 @@
1
+ import { SmartComponent } from '../../common/component';
2
+ import Toast from '../../toast/toast';
3
+ SmartComponent({
4
+ methods: {
5
+ showToast() {
6
+ Toast({ context: this, message: I18n.t('promptContent') });
7
+ },
8
+ showLongToast() {
9
+ Toast({
10
+ context: this,
11
+ message: I18n.t('toastDemoTip1'),
12
+ });
13
+ },
14
+ showLoadingToast() {
15
+ Toast.loading({
16
+ context: this,
17
+ message: I18n.t('loading') + '...',
18
+ forbidClick: true,
19
+ });
20
+ },
21
+ showCustomLoadingToast() {
22
+ Toast.loading({
23
+ context: this,
24
+ message: I18n.t('loading') + '...',
25
+ forbidClick: true,
26
+ loadingType: 'spinner',
27
+ });
28
+ },
29
+ showSuccessToast() {
30
+ Toast.success({ context: this, message: I18n.t('successMessage') });
31
+ },
32
+ showFailToast() {
33
+ Toast.fail({ context: this, message: I18n.t('failurePrompt') });
34
+ },
35
+ showWarnToast() {
36
+ Toast.warn({ context: this, message: I18n.t('warningPrompt') });
37
+ },
38
+ showCustomizedToast() {
39
+ const text = (second) => `${I18n.t('countdown')} ${second} ${I18n.t('second')}`;
40
+ const toast = Toast.loading({
41
+ context: this,
42
+ duration: 0,
43
+ forbidClick: true,
44
+ message: text(3),
45
+ });
46
+ let second = 3;
47
+ const timer = setInterval(() => {
48
+ second--;
49
+ if (second) {
50
+ toast === null || toast === void 0 ? void 0 : toast.setData({ message: text(second) });
51
+ }
52
+ else {
53
+ clearInterval(timer);
54
+ Toast.clear();
55
+ }
56
+ }, 1000);
57
+ },
58
+ showCustomizedWidthToast() {
59
+ Toast.loading({
60
+ context: this,
61
+ message: I18n.t('loading') + '...',
62
+ forbidClick: true,
63
+ width: 200,
64
+ });
65
+ },
66
+ },
67
+ });
@@ -24,9 +24,7 @@ function getContext() {
24
24
  }
25
25
  function Toast(toastOptions) {
26
26
  const options = Object.assign(Object.assign({}, currentOptions), parseOptions(toastOptions));
27
- const context = (typeof options.context === 'function'
28
- ? options.context()
29
- : options.context) || getContext();
27
+ const context = (typeof options.context === 'function' ? options.context() : options.context) || getContext();
30
28
  const toast = context.selectComponent(options.selector);
31
29
  if (!toast) {
32
30
  console.warn('未找到 smart-toast 节点,请确认 selector 及 context 是否正确');
@@ -46,7 +44,7 @@ function Toast(toastOptions) {
46
44
  if (options.duration != null && options.duration > 0) {
47
45
  toast.timer = setTimeout(() => {
48
46
  toast.clear();
49
- queue = queue.filter((item) => item !== toast);
47
+ queue = queue.filter(item => item !== toast);
50
48
  }, options.duration);
51
49
  }
52
50
  return toast;
@@ -57,7 +55,7 @@ Toast.success = createMethod('success');
57
55
  Toast.fail = createMethod('fail');
58
56
  Toast.warn = createMethod('warn');
59
57
  Toast.clear = () => {
60
- queue.forEach((toast) => {
58
+ queue.forEach(toast => {
61
59
  toast.clear();
62
60
  });
63
61
  queue = [];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,67 @@
1
+ import { SmartComponent } from '../../common/component';
2
+ SmartComponent({
3
+ data: {
4
+ show: false,
5
+ name: 'fade',
6
+ showCustom: false,
7
+ },
8
+ methods: {
9
+ onClickFade() {
10
+ this.trigger('fade');
11
+ },
12
+ onClickFadeUp() {
13
+ this.trigger('fade-up');
14
+ },
15
+ onClickFadeDown() {
16
+ this.trigger('fade-down');
17
+ },
18
+ onClickFadeLeft() {
19
+ this.trigger('fade-left');
20
+ },
21
+ onClickFadeRight() {
22
+ this.trigger('fade-right');
23
+ },
24
+ onClickSlideUp() {
25
+ this.trigger('slide-up');
26
+ },
27
+ onClickSlideDown() {
28
+ this.trigger('slide-down');
29
+ },
30
+ onClickSlideLeft() {
31
+ this.trigger('slide-left');
32
+ },
33
+ onClickSlideRight() {
34
+ this.trigger('slide-right');
35
+ },
36
+ trigger(name) {
37
+ this.setData({ name, show: true });
38
+ setTimeout(() => {
39
+ this.setData({ show: false });
40
+ }, 500);
41
+ },
42
+ onClickCustom() {
43
+ this.setData({ showCustom: true });
44
+ setTimeout(() => {
45
+ this.setData({ showCustom: false });
46
+ }, 1000);
47
+ },
48
+ onBeforeEnter() {
49
+ console.log('before enter');
50
+ },
51
+ onEnter() {
52
+ console.log('enter');
53
+ },
54
+ onAfterEnter() {
55
+ console.log('after enter');
56
+ },
57
+ onBeforeLeave() {
58
+ console.log('before leave');
59
+ },
60
+ onLeave() {
61
+ console.log('leave');
62
+ },
63
+ onAfterLeave() {
64
+ console.log('after leave');
65
+ },
66
+ },
67
+ });
@@ -0,0 +1 @@
1
+ export {};