@tdesign/uniapp 0.0.1-alpha.1 → 0.7.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 (700) hide show
  1. package/CHANGELOG.md +204 -0
  2. package/LICENSE +9 -0
  3. package/README.md +144 -0
  4. package/dist/.eslintrc.js +30 -0
  5. package/dist/action-sheet/README.en-US.md +60 -0
  6. package/dist/action-sheet/README.md +131 -0
  7. package/dist/action-sheet/action-sheet.css +162 -0
  8. package/dist/action-sheet/action-sheet.vue +350 -0
  9. package/dist/action-sheet/computed.js +15 -0
  10. package/dist/action-sheet/index.d.ts +11 -0
  11. package/dist/action-sheet/index.js +13 -0
  12. package/dist/action-sheet/props.ts +86 -0
  13. package/dist/action-sheet/show.d.ts +28 -0
  14. package/dist/action-sheet/show.js +33 -0
  15. package/dist/action-sheet/type.ts +93 -0
  16. package/dist/avatar/README.en-US.md +102 -0
  17. package/dist/avatar/README.md +152 -0
  18. package/dist/avatar/avatar.css +77 -0
  19. package/dist/avatar/avatar.vue +200 -0
  20. package/dist/avatar/computed.js +30 -0
  21. package/dist/avatar/props.ts +54 -0
  22. package/dist/avatar/type.ts +58 -0
  23. package/dist/avatar-group/avatar-group.css +187 -0
  24. package/dist/avatar-group/avatar-group.vue +121 -0
  25. package/dist/avatar-group/props.ts +44 -0
  26. package/dist/avatar-group/type.ts +38 -0
  27. package/dist/back-top/README.en-US.md +49 -0
  28. package/dist/back-top/README.md +67 -0
  29. package/dist/back-top/back-top.css +65 -0
  30. package/dist/back-top/back-top.vue +122 -0
  31. package/dist/back-top/props.ts +48 -0
  32. package/dist/back-top/type.ts +42 -0
  33. package/dist/badge/README.en-US.md +54 -0
  34. package/dist/badge/README.md +85 -0
  35. package/dist/badge/badge.css +140 -0
  36. package/dist/badge/badge.vue +134 -0
  37. package/dist/badge/computed.js +63 -0
  38. package/dist/badge/props.ts +55 -0
  39. package/dist/badge/type.ts +60 -0
  40. package/dist/button/README.en-US.md +238 -0
  41. package/dist/button/README.md +229 -0
  42. package/dist/button/button.css +514 -0
  43. package/dist/button/button.vue +244 -0
  44. package/dist/button/props.ts +207 -0
  45. package/dist/button/type.ts +192 -0
  46. package/dist/calendar/README.en-US.md +63 -0
  47. package/dist/calendar/README.md +113 -0
  48. package/dist/calendar/calendar-header.props.js +42 -0
  49. package/dist/calendar/calendar-header.vue +98 -0
  50. package/dist/calendar/calendar.css +205 -0
  51. package/dist/calendar/calendar.vue +454 -0
  52. package/dist/calendar/computed.js +42 -0
  53. package/dist/calendar/props.ts +113 -0
  54. package/dist/calendar/template.props.js +57 -0
  55. package/dist/calendar/template.vue +261 -0
  56. package/dist/calendar/type.ts +141 -0
  57. package/dist/calendar/utils.js +16 -0
  58. package/dist/cascader/README.en-US.md +56 -0
  59. package/dist/cascader/README.md +96 -0
  60. package/dist/cascader/cascader.css +102 -0
  61. package/dist/cascader/cascader.vue +519 -0
  62. package/dist/cascader/props.ts +73 -0
  63. package/dist/cascader/type.ts +77 -0
  64. package/dist/cell/README.en-US.md +116 -0
  65. package/dist/cell/README.md +147 -0
  66. package/dist/cell/cell.css +94 -0
  67. package/dist/cell/cell.vue +260 -0
  68. package/dist/cell/props.ts +87 -0
  69. package/dist/cell/type.ts +82 -0
  70. package/dist/cell-group/cell-group.css +44 -0
  71. package/dist/cell-group/cell-group.vue +69 -0
  72. package/dist/cell-group/props.ts +25 -0
  73. package/dist/cell-group/type.ts +23 -0
  74. package/dist/check-tag/check-tag.css +197 -0
  75. package/dist/check-tag/check-tag.vue +149 -0
  76. package/dist/check-tag/props.ts +67 -0
  77. package/dist/check-tag/type.ts +63 -0
  78. package/dist/checkbox/README.en-US.md +103 -0
  79. package/dist/checkbox/README.md +158 -0
  80. package/dist/checkbox/checkbox.css +174 -0
  81. package/dist/checkbox/checkbox.vue +238 -0
  82. package/dist/checkbox/props.ts +90 -0
  83. package/dist/checkbox/type.ts +96 -0
  84. package/dist/checkbox-group/checkbox-group.css +0 -0
  85. package/dist/checkbox-group/checkbox-group.vue +261 -0
  86. package/dist/checkbox-group/props.ts +58 -0
  87. package/dist/checkbox-group/type.ts +72 -0
  88. package/dist/col/README.en-US.md +31 -0
  89. package/dist/col/README.md +60 -0
  90. package/dist/col/col.css +149 -0
  91. package/dist/col/col.vue +58 -0
  92. package/dist/col/computed.js +14 -0
  93. package/dist/col/props.ts +16 -0
  94. package/dist/col/type.ts +16 -0
  95. package/dist/collapse/README.en-US.md +82 -0
  96. package/dist/collapse/README.md +119 -0
  97. package/dist/collapse/collapse.css +5 -0
  98. package/dist/collapse/collapse.vue +119 -0
  99. package/dist/collapse/props.ts +42 -0
  100. package/dist/collapse/type.ts +46 -0
  101. package/dist/collapse-panel/collapse-panel.css +154 -0
  102. package/dist/collapse-panel/collapse-panel.vue +238 -0
  103. package/dist/collapse-panel/props.ts +48 -0
  104. package/dist/collapse-panel/type.ts +41 -0
  105. package/dist/color-picker/README.en-US.md +62 -0
  106. package/dist/color-picker/README.md +110 -0
  107. package/dist/color-picker/color-picker.css +271 -0
  108. package/dist/color-picker/color-picker.vue +501 -0
  109. package/dist/color-picker/constants.ts +26 -0
  110. package/dist/color-picker/props.ts +75 -0
  111. package/dist/color-picker/template.props.js +58 -0
  112. package/dist/color-picker/template.vue +198 -0
  113. package/dist/color-picker/type.ts +96 -0
  114. package/dist/color-picker/utils.js +1 -0
  115. package/dist/common/bus.js +84 -0
  116. package/dist/common/canvas/index.js +53 -0
  117. package/dist/common/common.ts +173 -0
  118. package/dist/common/config.js +9 -0
  119. package/dist/common/dom/index.js +1 -0
  120. package/dist/common/dom/select-component.js +26 -0
  121. package/dist/common/event/dynamic.js +10 -0
  122. package/dist/common/functional/mixin.js +51 -0
  123. package/dist/common/relation/index.js +6 -0
  124. package/dist/common/relation/parent-map.js +26 -0
  125. package/dist/common/relation/relation.js +213 -0
  126. package/dist/common/route.js +13 -0
  127. package/dist/common/runtime/index.js +5 -0
  128. package/dist/common/runtime/relation.js +0 -0
  129. package/dist/common/runtime/wxs-polyfill.js +16 -0
  130. package/dist/common/shared/calendar/index.js +128 -0
  131. package/dist/common/shared/calendar/type.ts +14 -0
  132. package/dist/common/shared/color-picker/cmyk.js +78 -0
  133. package/dist/common/shared/color-picker/color.js +428 -0
  134. package/dist/common/shared/color-picker/gradient.js +180 -0
  135. package/dist/common/shared/color-picker/index.js +3 -0
  136. package/dist/common/shared/date.js +46 -0
  137. package/dist/common/shared/qrcode/qrcodegen.js +884 -0
  138. package/dist/common/shared/qrcode/utils.js +124 -0
  139. package/dist/common/src/control.js +66 -0
  140. package/dist/common/src/flatTool.js +99 -0
  141. package/dist/common/src/index.js +4 -0
  142. package/dist/common/src/instantiationDecorator.js +251 -0
  143. package/dist/common/src/superComponent.js +5 -0
  144. package/dist/common/style/_variables.less +232 -0
  145. package/dist/common/style/base.less +4 -0
  146. package/dist/common/style/icons.css +0 -0
  147. package/dist/common/style/index.css +13 -0
  148. package/dist/common/style/mixins/_border.less +34 -0
  149. package/dist/common/style/mixins/_clearfix.less +7 -0
  150. package/dist/common/style/mixins/_cursor.less +6 -0
  151. package/dist/common/style/mixins/_ellipsis.less +15 -0
  152. package/dist/common/style/mixins/_hairline.less +55 -0
  153. package/dist/common/style/mixins/_index.less +6 -0
  154. package/dist/common/style/mixins/_other.less +14 -0
  155. package/dist/common/style/theme/index.css +519 -0
  156. package/dist/common/style/theme/index.less +11 -0
  157. package/dist/common/style/theme/raw/_components.less +30 -0
  158. package/dist/common/style/theme/raw/_dark.less +178 -0
  159. package/dist/common/style/theme/raw/_font.less +90 -0
  160. package/dist/common/style/theme/raw/_light.less +182 -0
  161. package/dist/common/style/theme/raw/_radius.less +10 -0
  162. package/dist/common/style/theme/raw/_spacer.less +11 -0
  163. package/dist/common/style/utilities/index.css +13 -0
  164. package/dist/common/utils.js +358 -0
  165. package/dist/common/utils.wxs.js +139 -0
  166. package/dist/common/validator.js +38 -0
  167. package/dist/common/version.js +66 -0
  168. package/dist/common/wechat.js +22 -0
  169. package/dist/count-down/README.en-US.md +50 -0
  170. package/dist/count-down/README.md +76 -0
  171. package/dist/count-down/computed.js +3 -0
  172. package/dist/count-down/count-down.css +110 -0
  173. package/dist/count-down/count-down.vue +166 -0
  174. package/dist/count-down/props.ts +62 -0
  175. package/dist/count-down/type.ts +64 -0
  176. package/dist/count-down/utils.js +72 -0
  177. package/dist/date-time-picker/README.en-US.md +61 -0
  178. package/dist/date-time-picker/README.md +105 -0
  179. package/dist/date-time-picker/date-time-picker.css +4 -0
  180. package/dist/date-time-picker/date-time-picker.vue +570 -0
  181. package/dist/date-time-picker/locale/dayjs.js +81 -0
  182. package/dist/date-time-picker/locale/en.js +12 -0
  183. package/dist/date-time-picker/locale/ja.js +12 -0
  184. package/dist/date-time-picker/locale/ko.js +12 -0
  185. package/dist/date-time-picker/locale/ru.js +12 -0
  186. package/dist/date-time-picker/locale/tc.js +12 -0
  187. package/dist/date-time-picker/locale/zh.js +12 -0
  188. package/dist/date-time-picker/props.ts +114 -0
  189. package/dist/date-time-picker/type.ts +134 -0
  190. package/dist/demo/demo.vue +97 -0
  191. package/dist/demo/index.css +46 -0
  192. package/dist/demo-header/demo-header.vue +60 -0
  193. package/dist/demo-header/index.css +0 -0
  194. package/dist/demo-navbar/demo-navbar.vue +42 -0
  195. package/dist/dialog/README.en-US.md +69 -0
  196. package/dist/dialog/README.md +120 -0
  197. package/dist/dialog/computed.js +15 -0
  198. package/dist/dialog/dialog.css +102 -0
  199. package/dist/dialog/dialog.vue +422 -0
  200. package/dist/dialog/index.d.ts +42 -0
  201. package/dist/dialog/index.js +90 -0
  202. package/dist/dialog/props.ts +94 -0
  203. package/dist/dialog/type.ts +97 -0
  204. package/dist/divider/README.en-US.md +40 -0
  205. package/dist/divider/README.md +64 -0
  206. package/dist/divider/divider.css +56 -0
  207. package/dist/divider/divider.vue +79 -0
  208. package/dist/divider/props.ts +33 -0
  209. package/dist/divider/type.ts +27 -0
  210. package/dist/draggable/draggable.css +16 -0
  211. package/dist/draggable/draggable.vue +92 -0
  212. package/dist/draggable/props.js +19 -0
  213. package/dist/drawer/README.en-US.md +54 -0
  214. package/dist/drawer/README.md +80 -0
  215. package/dist/drawer/drawer.css +62 -0
  216. package/dist/drawer/drawer.vue +144 -0
  217. package/dist/drawer/props.ts +72 -0
  218. package/dist/drawer/type.ts +81 -0
  219. package/dist/dropdown-item/computed.js +6 -0
  220. package/dist/dropdown-item/dropdown-item.css +97 -0
  221. package/dist/dropdown-item/dropdown-item.vue +403 -0
  222. package/dist/dropdown-item/props.ts +71 -0
  223. package/dist/dropdown-item/type.ts +76 -0
  224. package/dist/dropdown-menu/README.en-US.md +95 -0
  225. package/dist/dropdown-menu/README.md +125 -0
  226. package/dist/dropdown-menu/dropdown-menu.css +59 -0
  227. package/dist/dropdown-menu/dropdown-menu.vue +188 -0
  228. package/dist/dropdown-menu/props.ts +44 -0
  229. package/dist/dropdown-menu/type.ts +41 -0
  230. package/dist/empty/README.en-US.md +39 -0
  231. package/dist/empty/README.md +69 -0
  232. package/dist/empty/empty.css +21 -0
  233. package/dist/empty/empty.vue +140 -0
  234. package/dist/empty/props.ts +20 -0
  235. package/dist/empty/type.ts +20 -0
  236. package/dist/fab/README.en-US.md +37 -0
  237. package/dist/fab/README.md +81 -0
  238. package/dist/fab/fab.css +9 -0
  239. package/dist/fab/fab.vue +238 -0
  240. package/dist/fab/props.ts +54 -0
  241. package/dist/fab/type.ts +57 -0
  242. package/dist/footer/README.en-US.md +33 -0
  243. package/dist/footer/README.md +61 -0
  244. package/dist/footer/footer.css +47 -0
  245. package/dist/footer/footer.vue +117 -0
  246. package/dist/footer/props.ts +23 -0
  247. package/dist/footer/type.ts +34 -0
  248. package/dist/form/README.en-US.md +137 -0
  249. package/dist/form/README.md +146 -0
  250. package/dist/form/form-item-props.ts +56 -0
  251. package/dist/form/form.css +169 -0
  252. package/dist/form/form.vue +287 -0
  253. package/dist/form/props.ts +109 -0
  254. package/dist/form/type.ts +387 -0
  255. package/dist/form-item/README.en-US.md +37 -0
  256. package/dist/form-item/README.md +37 -0
  257. package/dist/form-item/form-item.css +120 -0
  258. package/dist/form-item/form-item.vue +396 -0
  259. package/dist/form-item/form-model.ts +198 -0
  260. package/dist/form-item/props.ts +64 -0
  261. package/dist/form-item/type.ts +7 -0
  262. package/dist/grid/README.en-US.md +92 -0
  263. package/dist/grid/README.md +143 -0
  264. package/dist/grid/grid.css +13 -0
  265. package/dist/grid/grid.vue +94 -0
  266. package/dist/grid/props.ts +43 -0
  267. package/dist/grid/type.ts +43 -0
  268. package/dist/grid-item/README.en-US.md +65 -0
  269. package/dist/grid-item/README.md +65 -0
  270. package/dist/grid-item/grid-item.css +103 -0
  271. package/dist/grid-item/grid-item.vue +292 -0
  272. package/dist/grid-item/props.ts +63 -0
  273. package/dist/grid-item/type.ts +56 -0
  274. package/dist/guide/README.en-US.md +103 -0
  275. package/dist/guide/README.md +140 -0
  276. package/dist/guide/content.vue +325 -0
  277. package/dist/guide/guide.css +64 -0
  278. package/dist/guide/guide.vue +544 -0
  279. package/dist/guide/props.ts +98 -0
  280. package/dist/guide/type.ts +174 -0
  281. package/dist/icon/README.en-US.md +32 -0
  282. package/dist/icon/README.md +109 -0
  283. package/dist/icon/icon.css +7073 -0
  284. package/dist/icon/icon.vue +121 -0
  285. package/dist/icon/props.ts +35 -0
  286. package/dist/icon/type.ts +32 -0
  287. package/dist/image/README.en-US.md +51 -0
  288. package/dist/image/README.md +86 -0
  289. package/dist/image/image.css +44 -0
  290. package/dist/image/image.vue +207 -0
  291. package/dist/image/props.ts +71 -0
  292. package/dist/image/type.ts +85 -0
  293. package/dist/image-viewer/README.en-US.md +49 -0
  294. package/dist/image-viewer/README.md +78 -0
  295. package/dist/image-viewer/computed.js +4 -0
  296. package/dist/image-viewer/image-viewer.css +75 -0
  297. package/dist/image-viewer/image-viewer.vue +317 -0
  298. package/dist/image-viewer/props.ts +69 -0
  299. package/dist/image-viewer/type.ts +76 -0
  300. package/dist/indexes/README.en-US.md +76 -0
  301. package/dist/indexes/README.md +105 -0
  302. package/dist/indexes/computed.js +4 -0
  303. package/dist/indexes/indexes-anchor-props.ts +12 -0
  304. package/dist/indexes/indexes.css +50 -0
  305. package/dist/indexes/indexes.vue +371 -0
  306. package/dist/indexes/props.ts +40 -0
  307. package/dist/indexes/type.ts +38 -0
  308. package/dist/indexes-anchor/README.en-US.md +24 -0
  309. package/dist/indexes-anchor/README.md +28 -0
  310. package/dist/indexes-anchor/indexes-anchor.css +49 -0
  311. package/dist/indexes-anchor/indexes-anchor.vue +73 -0
  312. package/dist/indexes-anchor/props.ts +12 -0
  313. package/dist/indexes-anchor/type.ts +12 -0
  314. package/dist/input/README.en-US.md +121 -0
  315. package/dist/input/README.md +190 -0
  316. package/dist/input/computed.js +13 -0
  317. package/dist/input/input.css +161 -0
  318. package/dist/input/input.vue +407 -0
  319. package/dist/input/props.ts +247 -0
  320. package/dist/input/type.ts +237 -0
  321. package/dist/input/utils.js +38 -0
  322. package/dist/link/README.en-US.md +67 -0
  323. package/dist/link/README.md +115 -0
  324. package/dist/link/link.css +118 -0
  325. package/dist/link/link.vue +175 -0
  326. package/dist/link/props.ts +65 -0
  327. package/dist/link/type.ts +62 -0
  328. package/dist/loading/README.en-US.md +49 -0
  329. package/dist/loading/README.md +96 -0
  330. package/dist/loading/loading.css +203 -0
  331. package/dist/loading/loading.vue +157 -0
  332. package/dist/loading/props.ts +68 -0
  333. package/dist/loading/type.ts +70 -0
  334. package/dist/message/README.en-US.md +69 -0
  335. package/dist/message/README.md +105 -0
  336. package/dist/message/config.js +10 -0
  337. package/dist/message/index.d.ts +17 -0
  338. package/dist/message/index.js +39 -0
  339. package/dist/message/message.css +0 -0
  340. package/dist/message/message.interface.ts +30 -0
  341. package/dist/message/message.vue +275 -0
  342. package/dist/message/props.ts +101 -0
  343. package/dist/message/type.ts +101 -0
  344. package/dist/message-item/computed.js +23 -0
  345. package/dist/message-item/index.js +40 -0
  346. package/dist/message-item/message-item.css +63 -0
  347. package/dist/message-item/message-item.vue +353 -0
  348. package/dist/mixins/page-scroll.js +115 -0
  349. package/dist/mixins/skyline.js +12 -0
  350. package/dist/mixins/theme-change.js +16 -0
  351. package/dist/mixins/touch.js +29 -0
  352. package/dist/mixins/transition.js +133 -0
  353. package/dist/mixins/using-custom-navbar.js +38 -0
  354. package/dist/navbar/README.en-US.md +76 -0
  355. package/dist/navbar/README.md +121 -0
  356. package/dist/navbar/navbar.css +106 -0
  357. package/dist/navbar/navbar.vue +293 -0
  358. package/dist/navbar/props.ts +75 -0
  359. package/dist/navbar/type.ts +76 -0
  360. package/dist/notice-bar/README.en-US.md +62 -0
  361. package/dist/notice-bar/README.md +116 -0
  362. package/dist/notice-bar/notice-bar.css +75 -0
  363. package/dist/notice-bar/notice-bar.vue +326 -0
  364. package/dist/notice-bar/props.ts +71 -0
  365. package/dist/notice-bar/type.ts +71 -0
  366. package/dist/npm/dayjs/esm/constant.js +25 -0
  367. package/dist/npm/dayjs/esm/index.js +541 -0
  368. package/dist/npm/dayjs/esm/locale/en.js +12 -0
  369. package/dist/npm/dayjs/esm/locale/ja.js +45 -0
  370. package/dist/npm/dayjs/esm/locale/ko.js +45 -0
  371. package/dist/npm/dayjs/esm/locale/ru.js +99 -0
  372. package/dist/npm/dayjs/esm/locale/zh-cn.js +67 -0
  373. package/dist/npm/dayjs/esm/locale/zh-tw.js +65 -0
  374. package/dist/npm/dayjs/esm/plugin/localeData/index.js +114 -0
  375. package/dist/npm/dayjs/esm/plugin/localizedFormat/index.js +20 -0
  376. package/dist/npm/dayjs/esm/plugin/localizedFormat/utils.js +20 -0
  377. package/dist/npm/dayjs/esm/utils.js +58 -0
  378. package/dist/npm/tinycolor2/esm/tinycolor.js +1180 -0
  379. package/dist/overlay/README.en-US.md +34 -0
  380. package/dist/overlay/README.md +54 -0
  381. package/dist/overlay/overlay.css +17 -0
  382. package/dist/overlay/overlay.vue +105 -0
  383. package/dist/overlay/props.ts +37 -0
  384. package/dist/overlay/type.ts +42 -0
  385. package/dist/picker/README.en-US.md +77 -0
  386. package/dist/picker/README.md +112 -0
  387. package/dist/picker/picker.css +71 -0
  388. package/dist/picker/picker.vue +315 -0
  389. package/dist/picker/props.ts +95 -0
  390. package/dist/picker/type.ts +114 -0
  391. package/dist/picker-item/README.en-US.md +25 -0
  392. package/dist/picker-item/README.md +25 -0
  393. package/dist/picker-item/picker-item.css +32 -0
  394. package/dist/picker-item/picker-item.vue +446 -0
  395. package/dist/picker-item/props.ts +18 -0
  396. package/dist/picker-item/type.ts +23 -0
  397. package/dist/popover/README.en-US.md +55 -0
  398. package/dist/popover/README.md +85 -0
  399. package/dist/popover/popover.css +271 -0
  400. package/dist/popover/popover.vue +352 -0
  401. package/dist/popover/props.ts +58 -0
  402. package/dist/popover/type.ts +61 -0
  403. package/dist/popup/README.en-US.md +53 -0
  404. package/dist/popup/README.md +82 -0
  405. package/dist/popup/computed.js +14 -0
  406. package/dist/popup/popup.css +80 -0
  407. package/dist/popup/popup.vue +141 -0
  408. package/dist/popup/props.ts +67 -0
  409. package/dist/popup/type.ts +72 -0
  410. package/dist/progress/README.en-US.md +52 -0
  411. package/dist/progress/README.md +87 -0
  412. package/dist/progress/computed.js +81 -0
  413. package/dist/progress/progress.css +136 -0
  414. package/dist/progress/progress.vue +259 -0
  415. package/dist/progress/props.ts +55 -0
  416. package/dist/progress/type.ts +50 -0
  417. package/dist/progress/utils.js +19 -0
  418. package/dist/pull-down-refresh/README.en-US.md +60 -0
  419. package/dist/pull-down-refresh/README.md +83 -0
  420. package/dist/pull-down-refresh/props.ts +112 -0
  421. package/dist/pull-down-refresh/pull-down-refresh.css +29 -0
  422. package/dist/pull-down-refresh/pull-down-refresh.vue +366 -0
  423. package/dist/pull-down-refresh/type.ts +118 -0
  424. package/dist/qrcode/README.en-US.md +40 -0
  425. package/dist/qrcode/README.md +97 -0
  426. package/dist/qrcode/components/qrcode-canvas/props.ts +48 -0
  427. package/dist/qrcode/components/qrcode-canvas/qrcode-canvas.css +7 -0
  428. package/dist/qrcode/components/qrcode-canvas/qrcode-canvas.vue +413 -0
  429. package/dist/qrcode/components/qrcode-status/props.ts +22 -0
  430. package/dist/qrcode/components/qrcode-status/qrcode-status.css +25 -0
  431. package/dist/qrcode/components/qrcode-status/qrcode-status.vue +94 -0
  432. package/dist/qrcode/components/qrcode-status/type.ts +25 -0
  433. package/dist/qrcode/hooks/useQRCode.js +25 -0
  434. package/dist/qrcode/props.ts +66 -0
  435. package/dist/qrcode/qrcode.css +31 -0
  436. package/dist/qrcode/qrcode.vue +144 -0
  437. package/dist/qrcode/type.ts +66 -0
  438. package/dist/radio/README.en-US.md +104 -0
  439. package/dist/radio/README.md +148 -0
  440. package/dist/radio/props.ts +86 -0
  441. package/dist/radio/radio.css +177 -0
  442. package/dist/radio/radio.vue +227 -0
  443. package/dist/radio/type.ts +89 -0
  444. package/dist/radio-group/props.ts +68 -0
  445. package/dist/radio-group/radio-group.css +0 -0
  446. package/dist/radio-group/radio-group.vue +205 -0
  447. package/dist/radio-group/type.ts +79 -0
  448. package/dist/rate/README.en-US.md +50 -0
  449. package/dist/rate/README.md +107 -0
  450. package/dist/rate/computed.js +66 -0
  451. package/dist/rate/props.ts +85 -0
  452. package/dist/rate/rate.css +81 -0
  453. package/dist/rate/rate.vue +276 -0
  454. package/dist/rate/type.ts +79 -0
  455. package/dist/result/README.en-US.md +47 -0
  456. package/dist/result/README.md +88 -0
  457. package/dist/result/props.ts +36 -0
  458. package/dist/result/result.css +35 -0
  459. package/dist/result/result.vue +128 -0
  460. package/dist/result/type.ts +31 -0
  461. package/dist/row/computed.js +13 -0
  462. package/dist/row/props.ts +12 -0
  463. package/dist/row/row.css +6 -0
  464. package/dist/row/row.vue +63 -0
  465. package/dist/row/type.ts +12 -0
  466. package/dist/script/postinstall.js +46 -0
  467. package/dist/scroll-view/scroll-view.css +0 -0
  468. package/dist/scroll-view/scroll-view.vue +52 -0
  469. package/dist/search/README.en-US.md +88 -0
  470. package/dist/search/README.md +126 -0
  471. package/dist/search/computed.js +3 -0
  472. package/dist/search/props.ts +171 -0
  473. package/dist/search/search.css +75 -0
  474. package/dist/search/search.vue +285 -0
  475. package/dist/search/type.ts +165 -0
  476. package/dist/side-bar/README.en-US.md +58 -0
  477. package/dist/side-bar/README.md +89 -0
  478. package/dist/side-bar/props.ts +26 -0
  479. package/dist/side-bar/side-bar-item-props.ts +27 -0
  480. package/dist/side-bar/side-bar.css +14 -0
  481. package/dist/side-bar/side-bar.vue +84 -0
  482. package/dist/side-bar/type.ts +24 -0
  483. package/dist/side-bar-item/props.ts +27 -0
  484. package/dist/side-bar-item/side-bar-item.css +66 -0
  485. package/dist/side-bar-item/side-bar-item.vue +168 -0
  486. package/dist/side-bar-item/type.ts +32 -0
  487. package/dist/skeleton/README.en-US.md +44 -0
  488. package/dist/skeleton/README.md +82 -0
  489. package/dist/skeleton/props.ts +41 -0
  490. package/dist/skeleton/skeleton.css +77 -0
  491. package/dist/skeleton/skeleton.vue +211 -0
  492. package/dist/skeleton/type.ts +44 -0
  493. package/dist/slider/README.en-US.md +63 -0
  494. package/dist/slider/README.md +127 -0
  495. package/dist/slider/computed.js +9 -0
  496. package/dist/slider/props.ts +79 -0
  497. package/dist/slider/slider.css +239 -0
  498. package/dist/slider/slider.vue +719 -0
  499. package/dist/slider/tool.js +43 -0
  500. package/dist/slider/type.ts +81 -0
  501. package/dist/step-item/computed.js +4 -0
  502. package/dist/step-item/props.ts +36 -0
  503. package/dist/step-item/step-item.css +182 -0
  504. package/dist/step-item/step-item.vue +175 -0
  505. package/dist/step-item/type.ts +33 -0
  506. package/dist/stepper/README.en-US.md +49 -0
  507. package/dist/stepper/README.md +90 -0
  508. package/dist/stepper/props.ts +88 -0
  509. package/dist/stepper/stepper.css +105 -0
  510. package/dist/stepper/stepper.vue +223 -0
  511. package/dist/stepper/type.ts +79 -0
  512. package/dist/steps/README.en-US.md +99 -0
  513. package/dist/steps/README.md +157 -0
  514. package/dist/steps/props.ts +63 -0
  515. package/dist/steps/steps.css +19 -0
  516. package/dist/steps/steps.vue +122 -0
  517. package/dist/steps/type.ts +44 -0
  518. package/dist/sticky/README.en-US.md +32 -0
  519. package/dist/sticky/README.md +66 -0
  520. package/dist/sticky/props.ts +30 -0
  521. package/dist/sticky/sticky.css +3 -0
  522. package/dist/sticky/sticky.vue +144 -0
  523. package/dist/sticky/type.ts +31 -0
  524. package/dist/swipe-cell/README.en-US.md +29 -0
  525. package/dist/swipe-cell/README.md +66 -0
  526. package/dist/swipe-cell/computed.js +166 -0
  527. package/dist/swipe-cell/props.ts +39 -0
  528. package/dist/swipe-cell/swipe-cell.css +31 -0
  529. package/dist/swipe-cell/swipe-cell.vue +245 -0
  530. package/dist/swipe-cell/type.ts +48 -0
  531. package/dist/swiper/README.en-US.md +89 -0
  532. package/dist/swiper/README.md +139 -0
  533. package/dist/swiper/computed.js +29 -0
  534. package/dist/swiper/props.ts +117 -0
  535. package/dist/swiper/swiper.css +21 -0
  536. package/dist/swiper/swiper.vue +193 -0
  537. package/dist/swiper/type.ts +112 -0
  538. package/dist/swiper-nav/props.ts +49 -0
  539. package/dist/swiper-nav/swiper-nav.css +130 -0
  540. package/dist/swiper-nav/swiper-nav.vue +93 -0
  541. package/dist/swiper-nav/type.ts +45 -0
  542. package/dist/switch/README.en-US.md +70 -0
  543. package/dist/switch/README.md +104 -0
  544. package/dist/switch/props.ts +53 -0
  545. package/dist/switch/switch.css +123 -0
  546. package/dist/switch/switch.vue +122 -0
  547. package/dist/switch/type.ts +51 -0
  548. package/dist/tab-bar/README.en-US.md +58 -0
  549. package/dist/tab-bar/README.md +104 -0
  550. package/dist/tab-bar/props.ts +62 -0
  551. package/dist/tab-bar/tab-bar.css +42 -0
  552. package/dist/tab-bar/tab-bar.vue +141 -0
  553. package/dist/tab-bar/type.ts +56 -0
  554. package/dist/tab-bar-item/props.ts +25 -0
  555. package/dist/tab-bar-item/tab-bar-item.css +117 -0
  556. package/dist/tab-bar-item/tab-bar-item.vue +222 -0
  557. package/dist/tab-bar-item/type.ts +32 -0
  558. package/dist/tab-panel/props.ts +34 -0
  559. package/dist/tab-panel/tab-panel.css +15 -0
  560. package/dist/tab-panel/tab-panel.vue +100 -0
  561. package/dist/tab-panel/type.ts +42 -0
  562. package/dist/tabs/README.en-US.md +89 -0
  563. package/dist/tabs/README.md +198 -0
  564. package/dist/tabs/computed.js +26 -0
  565. package/dist/tabs/props.ts +80 -0
  566. package/dist/tabs/tabs.css +183 -0
  567. package/dist/tabs/tabs.vue +494 -0
  568. package/dist/tabs/type.ts +77 -0
  569. package/dist/tag/README.en-US.md +113 -0
  570. package/dist/tag/README.md +151 -0
  571. package/dist/tag/props.ts +70 -0
  572. package/dist/tag/tag.css +208 -0
  573. package/dist/tag/tag.vue +161 -0
  574. package/dist/tag/type.ts +54 -0
  575. package/dist/tdesign-uniapp/tdesign-uniapp.vue +11 -0
  576. package/dist/textarea/README.en-US.md +78 -0
  577. package/dist/textarea/README.md +132 -0
  578. package/dist/textarea/computed.js +14 -0
  579. package/dist/textarea/props.ts +152 -0
  580. package/dist/textarea/textarea.css +67 -0
  581. package/dist/textarea/textarea.vue +227 -0
  582. package/dist/textarea/type.ts +167 -0
  583. package/dist/toast/README.en-US.md +51 -0
  584. package/dist/toast/README.md +78 -0
  585. package/dist/toast/index.d.ts +20 -0
  586. package/dist/toast/index.js +27 -0
  587. package/dist/toast/props.ts +68 -0
  588. package/dist/toast/toast.css +73 -0
  589. package/dist/toast/toast.vue +213 -0
  590. package/dist/toast/type.ts +64 -0
  591. package/dist/transition/README.en-US.md +13 -0
  592. package/dist/transition/README.md +45 -0
  593. package/dist/transition/props.js +22 -0
  594. package/dist/transition/transition.css +14 -0
  595. package/dist/transition/transition.vue +51 -0
  596. package/dist/tree-select/README.en-US.md +48 -0
  597. package/dist/tree-select/README.md +78 -0
  598. package/dist/tree-select/computed.js +6 -0
  599. package/dist/tree-select/props.ts +42 -0
  600. package/dist/tree-select/tree-select.css +44 -0
  601. package/dist/tree-select/tree-select.vue +319 -0
  602. package/dist/tree-select/type.ts +49 -0
  603. package/dist/tsconfig.eslint.json +13 -0
  604. package/dist/types/action-sheet.d.ts +7 -0
  605. package/dist/types/avatar-group.d.ts +7 -0
  606. package/dist/types/avatar.d.ts +7 -0
  607. package/dist/types/back-top.d.ts +7 -0
  608. package/dist/types/badge.d.ts +7 -0
  609. package/dist/types/button.d.ts +7 -0
  610. package/dist/types/calendar.d.ts +7 -0
  611. package/dist/types/cascader.d.ts +7 -0
  612. package/dist/types/cell-group.d.ts +7 -0
  613. package/dist/types/cell.d.ts +7 -0
  614. package/dist/types/check-tag.d.ts +7 -0
  615. package/dist/types/checkbox-group.d.ts +7 -0
  616. package/dist/types/checkbox.d.ts +7 -0
  617. package/dist/types/col.d.ts +7 -0
  618. package/dist/types/collapse-panel.d.ts +7 -0
  619. package/dist/types/collapse.d.ts +7 -0
  620. package/dist/types/color-picker.d.ts +7 -0
  621. package/dist/types/count-down.d.ts +7 -0
  622. package/dist/types/date-time-picker.d.ts +7 -0
  623. package/dist/types/dialog.d.ts +7 -0
  624. package/dist/types/divider.d.ts +7 -0
  625. package/dist/types/drawer.d.ts +7 -0
  626. package/dist/types/dropdown-item.d.ts +7 -0
  627. package/dist/types/dropdown-menu.d.ts +7 -0
  628. package/dist/types/empty.d.ts +7 -0
  629. package/dist/types/fab.d.ts +7 -0
  630. package/dist/types/footer.d.ts +7 -0
  631. package/dist/types/form-item.d.ts +7 -0
  632. package/dist/types/form.d.ts +7 -0
  633. package/dist/types/grid-item.d.ts +7 -0
  634. package/dist/types/grid.d.ts +7 -0
  635. package/dist/types/guide.d.ts +7 -0
  636. package/dist/types/icon.d.ts +7 -0
  637. package/dist/types/image-viewer.d.ts +7 -0
  638. package/dist/types/image.d.ts +7 -0
  639. package/dist/types/index.d.ts +77 -0
  640. package/dist/types/indexes-anchor.d.ts +7 -0
  641. package/dist/types/indexes.d.ts +7 -0
  642. package/dist/types/input.d.ts +7 -0
  643. package/dist/types/link.d.ts +7 -0
  644. package/dist/types/loading.d.ts +7 -0
  645. package/dist/types/message.d.ts +7 -0
  646. package/dist/types/navbar.d.ts +7 -0
  647. package/dist/types/notice-bar.d.ts +7 -0
  648. package/dist/types/overlay.d.ts +7 -0
  649. package/dist/types/picker-item.d.ts +7 -0
  650. package/dist/types/picker.d.ts +7 -0
  651. package/dist/types/popup.d.ts +7 -0
  652. package/dist/types/progress.d.ts +7 -0
  653. package/dist/types/pull-down-refresh.d.ts +7 -0
  654. package/dist/types/qrcode.d.ts +7 -0
  655. package/dist/types/radio-group.d.ts +7 -0
  656. package/dist/types/radio.d.ts +7 -0
  657. package/dist/types/rate.d.ts +7 -0
  658. package/dist/types/result.d.ts +7 -0
  659. package/dist/types/row.d.ts +7 -0
  660. package/dist/types/search.d.ts +7 -0
  661. package/dist/types/side-bar-item.d.ts +7 -0
  662. package/dist/types/side-bar.d.ts +7 -0
  663. package/dist/types/skeleton.d.ts +7 -0
  664. package/dist/types/slider.d.ts +7 -0
  665. package/dist/types/step-item.d.ts +7 -0
  666. package/dist/types/stepper.d.ts +7 -0
  667. package/dist/types/steps.d.ts +7 -0
  668. package/dist/types/sticky.d.ts +7 -0
  669. package/dist/types/swipe-cell.d.ts +7 -0
  670. package/dist/types/swiper-nav.d.ts +7 -0
  671. package/dist/types/swiper.d.ts +7 -0
  672. package/dist/types/switch.d.ts +7 -0
  673. package/dist/types/tab-bar-item.d.ts +7 -0
  674. package/dist/types/tab-bar.d.ts +7 -0
  675. package/dist/types/tab-panel.d.ts +7 -0
  676. package/dist/types/tabs.d.ts +7 -0
  677. package/dist/types/tag.d.ts +7 -0
  678. package/dist/types/textarea.d.ts +7 -0
  679. package/dist/types/toast.d.ts +7 -0
  680. package/dist/types/tree-select.d.ts +7 -0
  681. package/dist/types/upload.d.ts +7 -0
  682. package/dist/types/watermark.d.ts +7 -0
  683. package/dist/upload/README.en-US.md +63 -0
  684. package/dist/upload/README.md +116 -0
  685. package/dist/upload/drag.computed.js +227 -0
  686. package/dist/upload/props.ts +136 -0
  687. package/dist/upload/type.ts +197 -0
  688. package/dist/upload/upload.computed.js +13 -0
  689. package/dist/upload/upload.css +116 -0
  690. package/dist/upload/upload.vue +887 -0
  691. package/dist/watermark/README.en-US.md +63 -0
  692. package/dist/watermark/README.md +115 -0
  693. package/dist/watermark/props.ts +82 -0
  694. package/dist/watermark/type.ts +121 -0
  695. package/dist/watermark/utils/generateBase64Url.js +360 -0
  696. package/dist/watermark/utils/randomMovingStyle.js +27 -0
  697. package/dist/watermark/watermark.css +28 -0
  698. package/dist/watermark/watermark.vue +200 -0
  699. package/global.d.ts +84 -0
  700. package/package.json +504 -8
@@ -0,0 +1,360 @@
1
+ import { loadImage } from '../../common/canvas/index';
2
+ import { getWindowInfo } from '../../common/utils';
3
+
4
+ const ratio = getWindowInfo().pixelRatio || 1;
5
+
6
+ // 元素中心为旋转点执行旋转
7
+ const drawRotate = (
8
+ ctx,
9
+ x,
10
+ y,
11
+ rotate,
12
+ ) => {
13
+ ctx.translate(x, y);
14
+ ctx.rotate((Math.PI / 180) * Number(rotate));
15
+ ctx.translate(-x, -y);
16
+ };
17
+
18
+ // 绘制文字
19
+ const drawText = (
20
+ ctx,
21
+ x,
22
+ y,
23
+ markHeight,
24
+ text,
25
+ fontWeight,
26
+ fontSize,
27
+ fontFamily,
28
+ fillStyle,
29
+ ) => {
30
+ ctx.font = `normal normal ${fontWeight} ${
31
+ fontSize * ratio
32
+ }px/${markHeight}px ${fontFamily}`;
33
+
34
+ ctx.fillStyle = fillStyle;
35
+ ctx.textAlign = 'start';
36
+ ctx.textBaseline = 'top';
37
+
38
+ ctx.fillText(text, x, y);
39
+ };
40
+
41
+ export default async function generateBase64Url(
42
+ canvas,
43
+ canvasId,
44
+ {
45
+ width,
46
+ height,
47
+ gapX,
48
+ gapY,
49
+ offsetLeft,
50
+ offsetTop,
51
+ rotate,
52
+ alpha,
53
+ watermarkContent,
54
+ lineSpace,
55
+ watermarkColor,
56
+ layout,
57
+ },
58
+ onFinish,
59
+ onFinally,
60
+ ) {
61
+ const isHexagonal = layout === 'hexagonal';
62
+
63
+ let ctx;
64
+
65
+ // #ifdef MP || H5
66
+ ctx = canvas.getContext('2d', { willReadFrequently: true });
67
+ // #endif
68
+
69
+ if (!ctx) {
70
+ ctx = uni.createCanvasContext(canvasId, this);
71
+ }
72
+ if (!ctx) {
73
+ console.warn('当前环境不支持Canvas, 无法绘制水印');
74
+ onFinish('');
75
+ return;
76
+ }
77
+
78
+ let actualBackgroundSize = {
79
+ width: gapX + width,
80
+ };
81
+
82
+ const canvasWidth = (gapX + width) * ratio;
83
+ const canvasHeight = (gapY + height) * ratio;
84
+
85
+ const markWidth = width * ratio;
86
+ const markHeight = height * ratio;
87
+
88
+ const dislocationRotateX = canvasWidth;
89
+ const dislocationRotateY = canvasHeight;
90
+ const dislocationDrawX = (gapX + width) * ratio;
91
+ const dislocationDrawY = (gapY + height) * ratio;
92
+
93
+ canvas.width = canvasWidth;
94
+ canvas.height = canvasHeight;
95
+
96
+ if (isHexagonal) {
97
+ canvas.width = canvasWidth * 2;
98
+ canvas.height = canvasHeight * 2;
99
+
100
+ // 两倍宽度+间距
101
+ actualBackgroundSize = {
102
+ width: gapX + width * 2 + width / 2,
103
+ };
104
+ }
105
+
106
+ ctx.globalAlpha = alpha;
107
+
108
+ // h5需要全局缩放
109
+ // #ifdef H5 || APP-PLUS
110
+ ctx.scale(1 / ratio, 1 / ratio);
111
+ // #endif
112
+
113
+ ctx.fillStyle = 'transparent';
114
+ ctx.fillRect(0, 0, markWidth, markHeight);
115
+
116
+ ctx.translate(offsetLeft * ratio, offsetTop * ratio);
117
+
118
+ const contents = Array.isArray(watermarkContent)
119
+ ? watermarkContent
120
+ : [{ ...watermarkContent }];
121
+
122
+ let top = 0;
123
+
124
+ // 预处理
125
+ contents.forEach((item) => {
126
+ item.top = top;
127
+ if (item.url) {
128
+ top += height;
129
+ } else if (item.text) {
130
+ top += lineSpace;
131
+ }
132
+ });
133
+
134
+
135
+ // 绘制水印内容
136
+ const renderWatermarkItem = async (
137
+ item,
138
+ offsetX = 0,
139
+ offsetY = 0,
140
+ rotateX = 0,
141
+ rotateY = 0,
142
+ ) => {
143
+ if (item.url) {
144
+ const { url, isGrayscale = false } = item;
145
+ const img = await loadImage({
146
+ canvas,
147
+ src: url,
148
+ });
149
+
150
+ ctx.save?.();
151
+ drawRotate(ctx, rotateX, rotateY, rotate);
152
+
153
+ // TODO:其他技术栈修复了「灰度效果只影响图片,不影响文字」的bug,因为小程序不能创建临时canvas,暂时没有想到比较优雅的解决方案
154
+ if (isGrayscale) {
155
+ // #ifdef APP-PLUS
156
+ ctx.drawImage(
157
+ img,
158
+ offsetX,
159
+ offsetY + item.top * ratio,
160
+ width * ratio / 2,
161
+ height * ratio / 2,
162
+ );
163
+ // #endif
164
+
165
+ // #ifndef APP-PLUS
166
+ ctx.drawImage(
167
+ img,
168
+ offsetX,
169
+ offsetY + item.top * ratio,
170
+ width * ratio,
171
+ height * ratio,
172
+ );
173
+ // #endif
174
+ const imgData = await getImageData(ctx, {
175
+ x: 0,
176
+ y: 0,
177
+ width,
178
+ height,
179
+ });
180
+ const pixels = imgData.data;
181
+ for (let i = 0; i < pixels.length; i += 4) {
182
+ const lightness = (pixels[i] + pixels[i + 1] + pixels[i + 2]) / 3;
183
+ pixels[i] = lightness;
184
+ pixels[i + 1] = lightness;
185
+ pixels[i + 2] = lightness;
186
+ }
187
+ await putImageData(ctx, imgData, {
188
+ x: 0,
189
+ y: 0,
190
+ });
191
+ } else {
192
+ // #ifdef APP-PLUS
193
+ ctx.drawImage(
194
+ img,
195
+ offsetX,
196
+ (offsetY + item.top * ratio),
197
+ width * ratio / 2,
198
+ height * ratio / 2,
199
+ );
200
+ // #endif
201
+
202
+ // #ifndef APP-PLUS
203
+ ctx.drawImage(
204
+ img,
205
+ offsetX,
206
+ offsetY + item.top * ratio,
207
+ width * ratio,
208
+ height * ratio,
209
+ );
210
+ // #endif
211
+ }
212
+
213
+ ctx.restore?.();
214
+ return;
215
+ }
216
+
217
+ if (item.text) {
218
+ const {
219
+ text,
220
+ fontSize = 16,
221
+ fontFamily = 'normal',
222
+ fontWeight = 'normal',
223
+ } = item;
224
+ const fillStyle = item?.fontColor || watermarkColor;
225
+
226
+ ctx.save?.();
227
+ drawRotate(ctx, rotateX, rotateY, rotate);
228
+ drawText(
229
+ ctx,
230
+ offsetX,
231
+ offsetY + item.top * ratio,
232
+ markHeight,
233
+ text,
234
+ fontWeight,
235
+ fontSize,
236
+ fontFamily,
237
+ fillStyle,
238
+ );
239
+ ctx.restore?.();
240
+ }
241
+ };
242
+
243
+ // 矩形水印
244
+ for (const item of contents) {
245
+ await renderWatermarkItem(item, 0, 0, 0, 0);
246
+ }
247
+
248
+ // 六边形水印
249
+ if (isHexagonal) {
250
+ for (const item of contents) {
251
+ await renderWatermarkItem(
252
+ item,
253
+ dislocationDrawX,
254
+ dislocationDrawY,
255
+ dislocationRotateX,
256
+ dislocationRotateY,
257
+ );
258
+ }
259
+ }
260
+ // #ifdef APP-PLUS
261
+ ctx.draw();
262
+ // #endif
263
+
264
+
265
+ // 没有图片
266
+ const canvasUrl = await exportCanvasImage.call(this, canvas, canvasId);
267
+ onFinish(canvasUrl, actualBackgroundSize, ratio);
268
+
269
+ onFinally?.();
270
+ }
271
+ // 跨平台 Canvas 导出方法
272
+ export function exportCanvasImage(canvas, canvasId) {
273
+ return new Promise((resolve, reject) => {
274
+ let parsed = false;
275
+ // #ifdef H5 || MP
276
+ resolve(canvas.toDataURL('image/png'));
277
+ parsed = true;
278
+ // #endif
279
+
280
+ if (parsed) return;
281
+ const query = uni.createSelectorQuery().in(this);
282
+
283
+ query
284
+ .select(`#${canvasId}`)
285
+ .fields({ node: true, size: true })
286
+ .exec(async (res) => {
287
+ if (!res[0]?.node) {
288
+ console.error('Canvas node not found');
289
+ return;
290
+ }
291
+
292
+ uni.canvasToTempFilePath({
293
+ // #ifdef MP
294
+ canvas: res[0].node,
295
+ // #endif
296
+ // #ifndef MP
297
+ canvasId,
298
+ // #endif
299
+ success: res => resolve(res.tempFilePath),
300
+ fail: reject,
301
+ });
302
+ });
303
+ });
304
+ }
305
+
306
+
307
+ async function getImageData(ctx, options) {
308
+ let result;
309
+ // #ifdef H5 || MP
310
+ result = ctx.getImageData(options.x, options.y, options.width, options.height);
311
+ // #endif
312
+
313
+ if (!result) {
314
+ result = new Promise((resolve) => {
315
+ uni.canvasGetImageData({
316
+ canvasId: options.canvasId,
317
+ x: options.x,
318
+ y: options.y,
319
+ width: options.width,
320
+ height: options.height,
321
+ success: (res) => {
322
+ // 小程序/App 返回的数据结构需要转换
323
+ resolve({
324
+ data: new Uint8ClampedArray(res.data),
325
+ width: res.width,
326
+ height: res.height,
327
+ });
328
+ },
329
+ }, this);
330
+ });
331
+ }
332
+
333
+ return result;
334
+ }
335
+
336
+
337
+ async function putImageData(ctx, imageData, options) {
338
+ let result;
339
+ // #ifdef H5 || MP
340
+ ctx.putImageData(imageData, options.x, options.y);
341
+ result = Promise.resolve();
342
+ // #endif
343
+
344
+ if (!result) {
345
+ result = new Promise((resolve, reject) => {
346
+ uni.canvasPutImageData({
347
+ canvasId: options.canvasId,
348
+ x: options.x,
349
+ y: options.y,
350
+ width: imageData.width,
351
+ height: imageData.height,
352
+ data: imageData.data,
353
+ success: resolve,
354
+ fail: reject,
355
+ }, this);
356
+ });
357
+ }
358
+
359
+ return result;
360
+ }
@@ -0,0 +1,27 @@
1
+ /* eslint-disable no-nested-ternary */
2
+ export default function randomMovingStyle() {
3
+ const align = Math.floor(Math.random() * 4);
4
+ const p1 = Math.floor(Math.random() * 70) + 30;
5
+ const leftTopLimit = 0;
6
+ const bottomLimit = 95;
7
+ const rightLimit = 90;
8
+ const left0 = align === 1 ? rightLimit : align === 3 ? leftTopLimit : p1;
9
+ const left25 = align === 0 ? rightLimit : align === 2 ? leftTopLimit : 100 - p1;
10
+ const left50 = align === 1 ? leftTopLimit : align === 3 ? rightLimit : 100 - p1;
11
+ const left75 = align === 0 ? leftTopLimit : align === 2 ? rightLimit : p1;
12
+ const top0 = align === 0 ? leftTopLimit : align === 2 ? bottomLimit : p1;
13
+ const top25 = align === 1 ? bottomLimit : align === 3 ? leftTopLimit : p1;
14
+ const top50 = align === 0 ? bottomLimit : align === 2 ? leftTopLimit : 100 - p1;
15
+ const top75 = align === 1 ? leftTopLimit : align === 3 ? bottomLimit : 100 - p1;
16
+
17
+ return {
18
+ left0: `${left0}%`,
19
+ left25: `${left25}%`,
20
+ left50: `${left50}%`,
21
+ left75: `${left75}%`,
22
+ top0: `${top0}%`,
23
+ top25: `${top25}%`,
24
+ top50: `${top50}%`,
25
+ top75: `${top75}%`,
26
+ };
27
+ }
@@ -0,0 +1,28 @@
1
+ .t-watermark {
2
+ position: relative;
3
+ overflow: hidden;
4
+ width: 100%;
5
+ }
6
+ @keyframes watermark {
7
+ 0% {
8
+ left: var(--watermark-left-0);
9
+ top: var(--watermark-top-0);
10
+ }
11
+ 25% {
12
+ left: var(--watermark-left-25);
13
+ top: var(--watermark-top-25);
14
+ }
15
+ 50% {
16
+ left: var(--watermark-left-50);
17
+ top: var(--watermark-top-50);
18
+ transform: translateX(-100%);
19
+ }
20
+ 75% {
21
+ left: var(--watermark-left-75);
22
+ top: var(--watermark-top-75);
23
+ }
24
+ 100% {
25
+ left: var(--watermark-left-0);
26
+ top: var(--watermark-top-0);
27
+ }
28
+ }
@@ -0,0 +1,200 @@
1
+ <template>
2
+ <view
3
+ :class="classPrefix + ' ' + tClass"
4
+ :style="tools._style([customStyle])"
5
+ >
6
+ <block v-if="content">
7
+ {{ content }}
8
+ </block>
9
+ <slot name="content" />
10
+ <slot />
11
+ <canvas
12
+ :id="canvasId"
13
+ :canvas-id="canvasId"
14
+ type="2d"
15
+ :style="canvasStyle"
16
+ />
17
+ <view
18
+ :class="movable ? 'watermark-move' : ''"
19
+ :style="tools._style(watermarkStyle)"
20
+ />
21
+ </view>
22
+ </template>
23
+
24
+ <script>
25
+ import tools from '../common/utils.wxs';
26
+ import watermarkProps from './props';
27
+ import { prefix } from '../common/config';
28
+ import { uniComponent } from '../common/src/index';
29
+ import { appBaseInfo, nextTick } from '../common/utils';
30
+ import generateBase64Url from './utils/generateBase64Url';
31
+ import randomMovingStyle from './utils/randomMovingStyle';
32
+
33
+ const name = `${prefix}-watermark`;
34
+
35
+ export default uniComponent({
36
+ name,
37
+ options: {
38
+ styleIsolation: 'shared',
39
+ },
40
+ externalClasses: [`${prefix}-class`],
41
+ props: {
42
+ ...watermarkProps,
43
+ },
44
+ data() {
45
+ return {
46
+ classPrefix: name,
47
+ tools,
48
+ watermarkStyle: {},
49
+ initialed: false,
50
+ canvasId: `watermark-canvas-${Math.random().toString(36)
51
+ .slice(2, 11)}`,
52
+ };
53
+ },
54
+ computed: {
55
+ canvasStyle() {
56
+ let result = 'width: 100px; height: 100px;';
57
+ let shouldHide = true;
58
+
59
+ // #ifdef APP-PLUS || MP-ALIPAY
60
+ if (!this.initialed) {
61
+ shouldHide = false;
62
+ }
63
+ // #endif
64
+
65
+ if (shouldHide) {
66
+ result += 'display: none;';
67
+ }
68
+ return result;
69
+ },
70
+ },
71
+ watch: {
72
+ watermarkContent: 'renderWatermark',
73
+ movable: 'renderWatermark',
74
+ rotate: 'renderWatermark',
75
+ x: 'renderWatermark',
76
+ y: 'renderWatermark',
77
+ width: 'renderWatermark',
78
+ height: 'renderWatermark',
79
+ alpha: 'renderWatermark',
80
+ lineSpace: 'renderWatermark',
81
+ moveInterval: 'renderWatermark',
82
+ zIndex: 'renderWatermark',
83
+ offset: 'renderWatermark',
84
+ removable: 'renderWatermark',
85
+ isRepeat: 'renderWatermark',
86
+ layout: 'renderWatermark',
87
+ },
88
+ async mounted() {
89
+ await nextTick();
90
+ this.renderWatermark();
91
+ },
92
+ methods: {
93
+ watermarkColor() {
94
+ return appBaseInfo.theme === 'dark'
95
+ ? 'rgba(238, 238, 238, 0.1)'
96
+ : 'rgba(0, 0, 0, 0.1)';
97
+ },
98
+ renderWatermark() {
99
+ const query = uni.createSelectorQuery().in(this);
100
+
101
+ query
102
+ .select(`#${this.canvasId}`)
103
+ .fields({ node: true, size: true })
104
+ .exec(async (res) => {
105
+ if (!res[0]?.node) {
106
+ console.error('Canvas node not found');
107
+ return;
108
+ }
109
+ const canvas = res[0].node;
110
+ const gapX = this.movable ? 0 : this.x;
111
+ const gapY = this.movable ? 0 : this.y;
112
+ const offset = this.offset || [];
113
+ const offsetLeft = offset[0] || gapX / 2;
114
+ const offsetTop = offset[1] || gapY / 2;
115
+
116
+ const bgImageOptions = {
117
+ width: this.width,
118
+ height: this.height,
119
+ rotate: this.movable ? 0 : this.rotate,
120
+ lineSpace: this.lineSpace,
121
+ alpha: this.alpha,
122
+ gapX,
123
+ gapY,
124
+ watermarkContent: this.watermarkContent,
125
+ offsetLeft,
126
+ offsetTop,
127
+ watermarkColor: this.watermarkColor(),
128
+ layout: this.layout,
129
+ };
130
+ generateBase64Url.call(
131
+ this,
132
+ canvas,
133
+ this.canvasId,
134
+ bgImageOptions,
135
+ (base64Url, backgroundSize) => {
136
+ let animationVars = {};
137
+ if (this.movable) {
138
+ const {
139
+ left0,
140
+ left25,
141
+ left50,
142
+ left75,
143
+ top0,
144
+ top25,
145
+ top50,
146
+ top75,
147
+ } = randomMovingStyle();
148
+ animationVars = {
149
+ '--watermark-left-0': left0,
150
+ '--watermark-left-25': left25,
151
+ '--watermark-left-50': left50,
152
+ '--watermark-left-75': left75,
153
+ '--watermark-top-0': top0,
154
+ '--watermark-top-25': top25,
155
+ '--watermark-top-50': top50,
156
+ '--watermark-top-75': top75,
157
+ '--watermark-animation-duration': `${
158
+ (this.moveInterval * 4) / 60
159
+ }s`,
160
+ };
161
+ }
162
+
163
+ this.watermarkStyle = {
164
+ zIndex: this.zIndex,
165
+ position: 'absolute',
166
+ left: 0,
167
+ right: 0,
168
+ top: 0,
169
+ bottom: 0,
170
+ width: '100%',
171
+ height: '100%',
172
+ backgroundSize: `${
173
+ backgroundSize?.width || gapX + this.width
174
+ }px`,
175
+ pointerEvents: 'none',
176
+ backgroundRepeat: this.movable ? 'no-repeat' : 'repeat',
177
+ backgroundImage: `url('${base64Url}')`,
178
+ ...animationVars,
179
+ };
180
+ },
181
+ () => {
182
+ this.initialed = true;
183
+ },
184
+ ).catch((e) => {
185
+ console.log('e', e);
186
+ });
187
+ });
188
+ },
189
+ },
190
+ });
191
+ </script>
192
+
193
+ <style scoped>
194
+ @import './watermark.css';
195
+
196
+ /* diff with td-mini */
197
+ .watermark-move {
198
+ animation: watermark var(--watermark-animation-duration, 100s) linear infinite;
199
+ }
200
+ </style>
package/global.d.ts ADDED
@@ -0,0 +1,84 @@
1
+ declare module 'vue' {
2
+ export interface GlobalComponents {
3
+ TActionSheet: typeof import('@tdesign/uniapp/action-sheet/action-sheet.vue').default;
4
+ TAvatar: typeof import('@tdesign/uniapp/avatar/avatar.vue').default;
5
+ TAvatarGroup: typeof import('@tdesign/uniapp/avatar-group/avatar-group.vue').default;
6
+ TBackTop: typeof import('@tdesign/uniapp/back-top/back-top.vue').default;
7
+ TBadge: typeof import('@tdesign/uniapp/badge/badge.vue').default;
8
+ TButton: typeof import('@tdesign/uniapp/button/button.vue').default;
9
+ TCalendar: typeof import('@tdesign/uniapp/calendar/calendar.vue').default;
10
+ TCascader: typeof import('@tdesign/uniapp/cascader/cascader.vue').default;
11
+ TCell: typeof import('@tdesign/uniapp/cell/cell.vue').default;
12
+ TCellGroup: typeof import('@tdesign/uniapp/cell-group/cell-group.vue').default;
13
+ TCheckTag: typeof import('@tdesign/uniapp/check-tag/check-tag.vue').default;
14
+ TCheckbox: typeof import('@tdesign/uniapp/checkbox/checkbox.vue').default;
15
+ TCheckboxGroup: typeof import('@tdesign/uniapp/checkbox-group/checkbox-group.vue').default;
16
+ TCol: typeof import('@tdesign/uniapp/col/col.vue').default;
17
+ TCollapse: typeof import('@tdesign/uniapp/collapse/collapse.vue').default;
18
+ TCollapsePanel: typeof import('@tdesign/uniapp/collapse-panel/collapse-panel.vue').default;
19
+ TColorPicker: typeof import('@tdesign/uniapp/color-picker/color-picker.vue').default;
20
+ TCountDown: typeof import('@tdesign/uniapp/count-down/count-down.vue').default;
21
+ TDateTimePicker: typeof import('@tdesign/uniapp/date-time-picker/date-time-picker.vue').default;
22
+ TDialog: typeof import('@tdesign/uniapp/dialog/dialog.vue').default;
23
+ TDivider: typeof import('@tdesign/uniapp/divider/divider.vue').default;
24
+ TDrawer: typeof import('@tdesign/uniapp/drawer/drawer.vue').default;
25
+ TDropdownItem: typeof import('@tdesign/uniapp/dropdown-item/dropdown-item.vue').default;
26
+ TDropdownMenu: typeof import('@tdesign/uniapp/dropdown-menu/dropdown-menu.vue').default;
27
+ TEmpty: typeof import('@tdesign/uniapp/empty/empty.vue').default;
28
+ TFab: typeof import('@tdesign/uniapp/fab/fab.vue').default;
29
+ TFooter: typeof import('@tdesign/uniapp/footer/footer.vue').default;
30
+ TForm: typeof import('@tdesign/uniapp/form/form.vue').default;
31
+ TFormItem: typeof import('@tdesign/uniapp/form-item/form-item.vue').default;
32
+ TGrid: typeof import('@tdesign/uniapp/grid/grid.vue').default;
33
+ TGridItem: typeof import('@tdesign/uniapp/grid-item/grid-item.vue').default;
34
+ TGuide: typeof import('@tdesign/uniapp/guide/guide.vue').default;
35
+ TIcon: typeof import('@tdesign/uniapp/icon/icon.vue').default;
36
+ TImage: typeof import('@tdesign/uniapp/image/image.vue').default;
37
+ TImageViewer: typeof import('@tdesign/uniapp/image-viewer/image-viewer.vue').default;
38
+ TIndexes: typeof import('@tdesign/uniapp/indexes/indexes.vue').default;
39
+ TIndexesAnchor: typeof import('@tdesign/uniapp/indexes-anchor/indexes-anchor.vue').default;
40
+ TInput: typeof import('@tdesign/uniapp/input/input.vue').default;
41
+ TLink: typeof import('@tdesign/uniapp/link/link.vue').default;
42
+ TLoading: typeof import('@tdesign/uniapp/loading/loading.vue').default;
43
+ TMessage: typeof import('@tdesign/uniapp/message/message.vue').default;
44
+ TNavbar: typeof import('@tdesign/uniapp/navbar/navbar.vue').default;
45
+ TNoticeBar: typeof import('@tdesign/uniapp/notice-bar/notice-bar.vue').default;
46
+ TOverlay: typeof import('@tdesign/uniapp/overlay/overlay.vue').default;
47
+ TPicker: typeof import('@tdesign/uniapp/picker/picker.vue').default;
48
+ TPickerItem: typeof import('@tdesign/uniapp/picker-item/picker-item.vue').default;
49
+ TPopup: typeof import('@tdesign/uniapp/popup/popup.vue').default;
50
+ TProgress: typeof import('@tdesign/uniapp/progress/progress.vue').default;
51
+ TPullDownRefresh: typeof import('@tdesign/uniapp/pull-down-refresh/pull-down-refresh.vue').default;
52
+ TQrcode: typeof import('@tdesign/uniapp/qrcode/qrcode.vue').default;
53
+ TRadio: typeof import('@tdesign/uniapp/radio/radio.vue').default;
54
+ TRadioGroup: typeof import('@tdesign/uniapp/radio-group/radio-group.vue').default;
55
+ TRate: typeof import('@tdesign/uniapp/rate/rate.vue').default;
56
+ TResult: typeof import('@tdesign/uniapp/result/result.vue').default;
57
+ TRow: typeof import('@tdesign/uniapp/row/row.vue').default;
58
+ TSearch: typeof import('@tdesign/uniapp/search/search.vue').default;
59
+ TSideBar: typeof import('@tdesign/uniapp/side-bar/side-bar.vue').default;
60
+ TSideBarItem: typeof import('@tdesign/uniapp/side-bar-item/side-bar-item.vue').default;
61
+ TSkeleton: typeof import('@tdesign/uniapp/skeleton/skeleton.vue').default;
62
+ TSlider: typeof import('@tdesign/uniapp/slider/slider.vue').default;
63
+ TStepItem: typeof import('@tdesign/uniapp/step-item/step-item.vue').default;
64
+ TStepper: typeof import('@tdesign/uniapp/stepper/stepper.vue').default;
65
+ TSteps: typeof import('@tdesign/uniapp/steps/steps.vue').default;
66
+ TSticky: typeof import('@tdesign/uniapp/sticky/sticky.vue').default;
67
+ TSwipeCell: typeof import('@tdesign/uniapp/swipe-cell/swipe-cell.vue').default;
68
+ TSwiper: typeof import('@tdesign/uniapp/swiper/swiper.vue').default;
69
+ TSwiperNav: typeof import('@tdesign/uniapp/swiper-nav/swiper-nav.vue').default;
70
+ TSwitch: typeof import('@tdesign/uniapp/switch/switch.vue').default;
71
+ TTabBar: typeof import('@tdesign/uniapp/tab-bar/tab-bar.vue').default;
72
+ TTabBarItem: typeof import('@tdesign/uniapp/tab-bar-item/tab-bar-item.vue').default;
73
+ TTabPanel: typeof import('@tdesign/uniapp/tab-panel/tab-panel.vue').default;
74
+ TTabs: typeof import('@tdesign/uniapp/tabs/tabs.vue').default;
75
+ TTag: typeof import('@tdesign/uniapp/tag/tag.vue').default;
76
+ TTextarea: typeof import('@tdesign/uniapp/textarea/textarea.vue').default;
77
+ TToast: typeof import('@tdesign/uniapp/toast/toast.vue').default;
78
+ TTreeSelect: typeof import('@tdesign/uniapp/tree-select/tree-select.vue').default;
79
+ TUpload: typeof import('@tdesign/uniapp/upload/upload.vue').default;
80
+ TWatermark: typeof import('@tdesign/uniapp/watermark/watermark.vue').default;
81
+ }
82
+ }
83
+
84
+ export {};