@tplc/wot 0.0.1

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 (328) hide show
  1. package/components/common/AbortablePromise.ts +36 -0
  2. package/components/common/abstracts/_config.scss +7 -0
  3. package/components/common/abstracts/_function.scss +76 -0
  4. package/components/common/abstracts/_mixin.scss +339 -0
  5. package/components/common/abstracts/variable.scss +1346 -0
  6. package/components/common/base64.ts +30 -0
  7. package/components/common/canvasHelper.ts +49 -0
  8. package/components/common/clickoutside.ts +34 -0
  9. package/components/common/dayjs.ts +157 -0
  10. package/components/common/event.ts +8 -0
  11. package/components/common/props.ts +51 -0
  12. package/components/common/util.ts +751 -0
  13. package/components/composables/useCell.ts +13 -0
  14. package/components/composables/useChildren.ts +122 -0
  15. package/components/composables/useCountDown.ts +138 -0
  16. package/components/composables/useLockScroll.ts +39 -0
  17. package/components/composables/useParent.ts +41 -0
  18. package/components/composables/usePopover.ts +193 -0
  19. package/components/composables/useQueue.ts +52 -0
  20. package/components/composables/useRaf.ts +37 -0
  21. package/components/composables/useTouch.ts +44 -0
  22. package/components/composables/useTranslate.ts +22 -0
  23. package/components/wd-action-sheet/index.scss +204 -0
  24. package/components/wd-action-sheet/types.ts +128 -0
  25. package/components/wd-action-sheet/wd-action-sheet.vue +174 -0
  26. package/components/wd-backtop/index.scss +25 -0
  27. package/components/wd-backtop/types.ts +37 -0
  28. package/components/wd-backtop/wd-backtop.vue +48 -0
  29. package/components/wd-badge/index.scss +59 -0
  30. package/components/wd-badge/types.ts +53 -0
  31. package/components/wd-badge/wd-badge.vue +69 -0
  32. package/components/wd-button/index.scss +340 -0
  33. package/components/wd-button/types.ts +112 -0
  34. package/components/wd-button/wd-button.vue +176 -0
  35. package/components/wd-calendar/index.scss +244 -0
  36. package/components/wd-calendar/types.ts +235 -0
  37. package/components/wd-calendar/wd-calendar.vue +456 -0
  38. package/components/wd-calendar-view/index.scss +9 -0
  39. package/components/wd-calendar-view/month/index.scss +151 -0
  40. package/components/wd-calendar-view/month/month.vue +391 -0
  41. package/components/wd-calendar-view/month/types.ts +19 -0
  42. package/components/wd-calendar-view/monthPanel/index.scss +89 -0
  43. package/components/wd-calendar-view/monthPanel/month-panel.vue +388 -0
  44. package/components/wd-calendar-view/monthPanel/types.ts +48 -0
  45. package/components/wd-calendar-view/types.ts +134 -0
  46. package/components/wd-calendar-view/utils.ts +451 -0
  47. package/components/wd-calendar-view/wd-calendar-view.vue +111 -0
  48. package/components/wd-calendar-view/year/index.scss +148 -0
  49. package/components/wd-calendar-view/year/types.ts +19 -0
  50. package/components/wd-calendar-view/year/year.vue +220 -0
  51. package/components/wd-calendar-view/yearPanel/index.scss +24 -0
  52. package/components/wd-calendar-view/yearPanel/types.ts +38 -0
  53. package/components/wd-calendar-view/yearPanel/year-panel.vue +140 -0
  54. package/components/wd-card/index.scss +70 -0
  55. package/components/wd-card/types.ts +30 -0
  56. package/components/wd-card/wd-card.vue +40 -0
  57. package/components/wd-cell/index.scss +189 -0
  58. package/components/wd-cell/types.ts +96 -0
  59. package/components/wd-cell/wd-cell.vue +135 -0
  60. package/components/wd-cell-group/index.scss +55 -0
  61. package/components/wd-cell-group/types.ts +41 -0
  62. package/components/wd-cell-group/wd-cell-group.vue +45 -0
  63. package/components/wd-checkbox/index.scss +285 -0
  64. package/components/wd-checkbox/types.ts +68 -0
  65. package/components/wd-checkbox/wd-checkbox.vue +185 -0
  66. package/components/wd-checkbox-group/index.scss +20 -0
  67. package/components/wd-checkbox-group/types.ts +59 -0
  68. package/components/wd-checkbox-group/wd-checkbox-group.vue +103 -0
  69. package/components/wd-circle/index.scss +18 -0
  70. package/components/wd-circle/types.ts +54 -0
  71. package/components/wd-circle/wd-circle.vue +318 -0
  72. package/components/wd-col/index.scss +19 -0
  73. package/components/wd-col/types.ts +15 -0
  74. package/components/wd-col/wd-col.vue +91 -0
  75. package/components/wd-col-picker/index.scss +241 -0
  76. package/components/wd-col-picker/types.ts +170 -0
  77. package/components/wd-col-picker/wd-col-picker.vue +550 -0
  78. package/components/wd-collapse/index.scss +55 -0
  79. package/components/wd-collapse/types.ts +63 -0
  80. package/components/wd-collapse/wd-collapse.vue +160 -0
  81. package/components/wd-collapse-item/index.scss +79 -0
  82. package/components/wd-collapse-item/types.ts +36 -0
  83. package/components/wd-collapse-item/wd-collapse-item.vue +182 -0
  84. package/components/wd-config-provider/types.ts +1023 -0
  85. package/components/wd-config-provider/wd-config-provider.vue +82 -0
  86. package/components/wd-count-down/index.scss +14 -0
  87. package/components/wd-count-down/types.ts +41 -0
  88. package/components/wd-count-down/utils.ts +52 -0
  89. package/components/wd-count-down/wd-count-down.vue +60 -0
  90. package/components/wd-count-to/index.scss +6 -0
  91. package/components/wd-count-to/types.ts +110 -0
  92. package/components/wd-count-to/wd-count-to.vue +134 -0
  93. package/components/wd-curtain/index.scss +80 -0
  94. package/components/wd-curtain/types.ts +45 -0
  95. package/components/wd-curtain/wd-curtain.vue +174 -0
  96. package/components/wd-datetime-picker/index.scss +243 -0
  97. package/components/wd-datetime-picker/types.ts +225 -0
  98. package/components/wd-datetime-picker/wd-datetime-picker.vue +827 -0
  99. package/components/wd-datetime-picker-view/index.scss +0 -0
  100. package/components/wd-datetime-picker-view/types.ts +137 -0
  101. package/components/wd-datetime-picker-view/wd-datetime-picker-view.vue +514 -0
  102. package/components/wd-divider/index.scss +32 -0
  103. package/components/wd-divider/types.ts +12 -0
  104. package/components/wd-divider/wd-divider.vue +29 -0
  105. package/components/wd-drop-menu/index.scss +89 -0
  106. package/components/wd-drop-menu/types.ts +38 -0
  107. package/components/wd-drop-menu/wd-drop-menu.vue +128 -0
  108. package/components/wd-drop-menu-item/index.scss +66 -0
  109. package/components/wd-drop-menu-item/types.ts +78 -0
  110. package/components/wd-drop-menu-item/wd-drop-menu-item.vue +230 -0
  111. package/components/wd-fab/index.scss +115 -0
  112. package/components/wd-fab/types.ts +61 -0
  113. package/components/wd-fab/wd-fab.vue +257 -0
  114. package/components/wd-form/index.scss +10 -0
  115. package/components/wd-form/types.ts +93 -0
  116. package/components/wd-form/wd-form.vue +185 -0
  117. package/components/wd-form-item/index.scss +17 -0
  118. package/components/wd-form-item/types.ts +22 -0
  119. package/components/wd-form-item/wd-form-item.vue +65 -0
  120. package/components/wd-gap/index.scss +9 -0
  121. package/components/wd-gap/types.ts +23 -0
  122. package/components/wd-gap/wd-gap.vue +39 -0
  123. package/components/wd-grid/index.scss +9 -0
  124. package/components/wd-grid/types.ts +54 -0
  125. package/components/wd-grid/wd-grid.vue +107 -0
  126. package/components/wd-grid-item/index.scss +137 -0
  127. package/components/wd-grid-item/types.ts +74 -0
  128. package/components/wd-grid-item/wd-grid-item.vue +181 -0
  129. package/components/wd-icon/index.scss +1222 -0
  130. package/components/wd-icon/types.ts +21 -0
  131. package/components/wd-icon/wd-icon.vue +53 -0
  132. package/components/wd-icon/wd-icons.ttf +0 -0
  133. package/components/wd-img/index.scss +19 -0
  134. package/components/wd-img/types.ts +53 -0
  135. package/components/wd-img/wd-img.vue +76 -0
  136. package/components/wd-img-cropper/index.scss +227 -0
  137. package/components/wd-img-cropper/types.ts +87 -0
  138. package/components/wd-img-cropper/wd-img-cropper.vue +659 -0
  139. package/components/wd-index-anchor/index.scss +34 -0
  140. package/components/wd-index-anchor/type.ts +9 -0
  141. package/components/wd-index-anchor/wd-index-anchor.vue +57 -0
  142. package/components/wd-index-bar/index.scss +39 -0
  143. package/components/wd-index-bar/type.ts +28 -0
  144. package/components/wd-index-bar/wd-index-bar.vue +158 -0
  145. package/components/wd-input/index.scss +326 -0
  146. package/components/wd-input/types.ts +182 -0
  147. package/components/wd-input/wd-input.vue +327 -0
  148. package/components/wd-input-number/index.scss +132 -0
  149. package/components/wd-input-number/types.ts +78 -0
  150. package/components/wd-input-number/wd-input-number.vue +221 -0
  151. package/components/wd-loading/index.scss +34 -0
  152. package/components/wd-loading/types.ts +31 -0
  153. package/components/wd-loading/wd-loading.vue +90 -0
  154. package/components/wd-loadmore/index.scss +39 -0
  155. package/components/wd-loadmore/types.ts +24 -0
  156. package/components/wd-loadmore/wd-loadmore.vue +53 -0
  157. package/components/wd-message-box/index.scss +121 -0
  158. package/components/wd-message-box/index.ts +95 -0
  159. package/components/wd-message-box/types.ts +116 -0
  160. package/components/wd-message-box/wd-message-box.vue +326 -0
  161. package/components/wd-navbar/index.scss +103 -0
  162. package/components/wd-navbar/types.ts +52 -0
  163. package/components/wd-navbar/wd-navbar.vue +142 -0
  164. package/components/wd-navbar-capsule/index.scss +65 -0
  165. package/components/wd-navbar-capsule/types.ts +0 -0
  166. package/components/wd-navbar-capsule/wd-navbar-capsule.vue +31 -0
  167. package/components/wd-notice-bar/index.scss +86 -0
  168. package/components/wd-notice-bar/types.ts +56 -0
  169. package/components/wd-notice-bar/wd-notice-bar.vue +223 -0
  170. package/components/wd-notify/index.scss +34 -0
  171. package/components/wd-notify/index.ts +59 -0
  172. package/components/wd-notify/types.ts +62 -0
  173. package/components/wd-notify/wd-notify.vue +83 -0
  174. package/components/wd-number-keyboard/index.scss +78 -0
  175. package/components/wd-number-keyboard/key/index.scss +79 -0
  176. package/components/wd-number-keyboard/key/index.vue +76 -0
  177. package/components/wd-number-keyboard/key/types.ts +11 -0
  178. package/components/wd-number-keyboard/types.ts +79 -0
  179. package/components/wd-number-keyboard/wd-number-keyboard.vue +173 -0
  180. package/components/wd-overlay/index.scss +17 -0
  181. package/components/wd-overlay/types.ts +25 -0
  182. package/components/wd-overlay/wd-overlay.vue +46 -0
  183. package/components/wd-pagination/index.scss +57 -0
  184. package/components/wd-pagination/types.ts +41 -0
  185. package/components/wd-pagination/wd-pagination.vue +121 -0
  186. package/components/wd-password-input/index.scss +123 -0
  187. package/components/wd-password-input/types.ts +48 -0
  188. package/components/wd-password-input/wd-password-input.vue +58 -0
  189. package/components/wd-picker/index.scss +216 -0
  190. package/components/wd-picker/types.ts +186 -0
  191. package/components/wd-picker/wd-picker.vue +409 -0
  192. package/components/wd-picker-view/index.scss +91 -0
  193. package/components/wd-picker-view/types.ts +162 -0
  194. package/components/wd-picker-view/wd-picker-view.vue +361 -0
  195. package/components/wd-popover/index.scss +123 -0
  196. package/components/wd-popover/types.ts +69 -0
  197. package/components/wd-popover/wd-popover.vue +216 -0
  198. package/components/wd-popup/index.scss +112 -0
  199. package/components/wd-popup/types.ts +68 -0
  200. package/components/wd-popup/wd-popup.vue +227 -0
  201. package/components/wd-progress/index.scss +62 -0
  202. package/components/wd-progress/types.ts +40 -0
  203. package/components/wd-progress/wd-progress.vue +201 -0
  204. package/components/wd-radio/index.scss +300 -0
  205. package/components/wd-radio/types.ts +42 -0
  206. package/components/wd-radio/wd-radio.vue +136 -0
  207. package/components/wd-radio-group/index.scss +23 -0
  208. package/components/wd-radio-group/types.ts +36 -0
  209. package/components/wd-radio-group/wd-radio-group.vue +54 -0
  210. package/components/wd-rate/index.scss +24 -0
  211. package/components/wd-rate/types.ts +91 -0
  212. package/components/wd-rate/wd-rate.vue +131 -0
  213. package/components/wd-resize/index.scss +26 -0
  214. package/components/wd-resize/types.ts +6 -0
  215. package/components/wd-resize/wd-resize.vue +155 -0
  216. package/components/wd-row/index.scss +10 -0
  217. package/components/wd-row/types.ts +16 -0
  218. package/components/wd-row/wd-row.vue +63 -0
  219. package/components/wd-search/index.scss +148 -0
  220. package/components/wd-search/types.ts +83 -0
  221. package/components/wd-search/wd-search.vue +237 -0
  222. package/components/wd-segmented/index.scss +97 -0
  223. package/components/wd-segmented/types.ts +68 -0
  224. package/components/wd-segmented/wd-segmented.vue +143 -0
  225. package/components/wd-select-picker/index.scss +177 -0
  226. package/components/wd-select-picker/types.ts +116 -0
  227. package/components/wd-select-picker/wd-select-picker.vue +486 -0
  228. package/components/wd-sidebar/index.scss +25 -0
  229. package/components/wd-sidebar/types.ts +28 -0
  230. package/components/wd-sidebar/wd-sidebar.vue +41 -0
  231. package/components/wd-sidebar-item/index.scss +93 -0
  232. package/components/wd-sidebar-item/types.ts +31 -0
  233. package/components/wd-sidebar-item/wd-sidebar-item.vue +114 -0
  234. package/components/wd-skeleton/index.scss +101 -0
  235. package/components/wd-skeleton/index.ts +1 -0
  236. package/components/wd-skeleton/types.ts +69 -0
  237. package/components/wd-skeleton/wd-skeleton.vue +135 -0
  238. package/components/wd-slider/index.scss +91 -0
  239. package/components/wd-slider/types.ts +104 -0
  240. package/components/wd-slider/wd-slider.vue +377 -0
  241. package/components/wd-sort-button/index.scss +86 -0
  242. package/components/wd-sort-button/types.ts +43 -0
  243. package/components/wd-sort-button/wd-sort-button.vue +76 -0
  244. package/components/wd-status-tip/index.scss +37 -0
  245. package/components/wd-status-tip/types.ts +59 -0
  246. package/components/wd-status-tip/wd-status-tip.vue +94 -0
  247. package/components/wd-step/index.scss +236 -0
  248. package/components/wd-step/types.ts +33 -0
  249. package/components/wd-step/wd-step.vue +151 -0
  250. package/components/wd-steps/index.scss +10 -0
  251. package/components/wd-steps/types.ts +59 -0
  252. package/components/wd-steps/wd-steps.vue +37 -0
  253. package/components/wd-sticky/index.scss +9 -0
  254. package/components/wd-sticky/types.ts +13 -0
  255. package/components/wd-sticky/wd-sticky.vue +190 -0
  256. package/components/wd-sticky-box/index.scss +6 -0
  257. package/components/wd-sticky-box/types.ts +20 -0
  258. package/components/wd-sticky-box/wd-sticky-box.vue +154 -0
  259. package/components/wd-swipe-action/index.scss +22 -0
  260. package/components/wd-swipe-action/types.ts +43 -0
  261. package/components/wd-swipe-action/wd-swipe-action.vue +307 -0
  262. package/components/wd-swiper/index.scss +23 -0
  263. package/components/wd-swiper/types.ts +189 -0
  264. package/components/wd-swiper/wd-swiper.vue +202 -0
  265. package/components/wd-swiper-nav/index.scss +153 -0
  266. package/components/wd-swiper-nav/types.ts +42 -0
  267. package/components/wd-swiper-nav/wd-swiper-nav.vue +37 -0
  268. package/components/wd-switch/index.scss +58 -0
  269. package/components/wd-switch/types.ts +56 -0
  270. package/components/wd-switch/wd-switch.vue +83 -0
  271. package/components/wd-tab/index.scss +8 -0
  272. package/components/wd-tab/types.ts +20 -0
  273. package/components/wd-tab/wd-tab.vue +100 -0
  274. package/components/wd-tabbar/index.scss +57 -0
  275. package/components/wd-tabbar/types.ts +88 -0
  276. package/components/wd-tabbar/wd-tabbar.vue +104 -0
  277. package/components/wd-tabbar-item/index.scss +52 -0
  278. package/components/wd-tabbar-item/types.ts +51 -0
  279. package/components/wd-tabbar-item/wd-tabbar-item.vue +101 -0
  280. package/components/wd-table/index.scss +132 -0
  281. package/components/wd-table/types.ts +69 -0
  282. package/components/wd-table/wd-table.vue +255 -0
  283. package/components/wd-table-col/index.scss +44 -0
  284. package/components/wd-table-col/types.ts +54 -0
  285. package/components/wd-table-col/wd-table-col.vue +149 -0
  286. package/components/wd-tabs/index.scss +280 -0
  287. package/components/wd-tabs/types.ts +71 -0
  288. package/components/wd-tabs/wd-tabs.vue +528 -0
  289. package/components/wd-tag/index.scss +115 -0
  290. package/components/wd-tag/types.ts +81 -0
  291. package/components/wd-tag/wd-tag.vue +154 -0
  292. package/components/wd-text/index.scss +34 -0
  293. package/components/wd-text/types.ts +98 -0
  294. package/components/wd-text/wd-text.vue +138 -0
  295. package/components/wd-textarea/index.scss +343 -0
  296. package/components/wd-textarea/types.ts +298 -0
  297. package/components/wd-textarea/wd-textarea.vue +303 -0
  298. package/components/wd-toast/index.scss +66 -0
  299. package/components/wd-toast/index.ts +109 -0
  300. package/components/wd-toast/types.ts +76 -0
  301. package/components/wd-toast/wd-toast.vue +212 -0
  302. package/components/wd-tooltip/index.scss +61 -0
  303. package/components/wd-tooltip/types.ts +102 -0
  304. package/components/wd-tooltip/wd-tooltip.vue +167 -0
  305. package/components/wd-transition/index.scss +91 -0
  306. package/components/wd-transition/types.ts +89 -0
  307. package/components/wd-transition/wd-transition.vue +221 -0
  308. package/components/wd-upload/index.scss +173 -0
  309. package/components/wd-upload/types.ts +378 -0
  310. package/components/wd-upload/utils.ts +152 -0
  311. package/components/wd-upload/wd-upload.vue +737 -0
  312. package/components/wd-video-preview/index.scss +34 -0
  313. package/components/wd-video-preview/types.ts +32 -0
  314. package/components/wd-video-preview/wd-video-preview.vue +76 -0
  315. package/components/wd-watermark/index.scss +18 -0
  316. package/components/wd-watermark/types.ts +82 -0
  317. package/components/wd-watermark/wd-watermark.vue +592 -0
  318. package/components/wot-design-uni/wot-design-uni.vue +14 -0
  319. package/global.d.ts +108 -0
  320. package/index.ts +30 -0
  321. package/locale/index.ts +41 -0
  322. package/locale/lang/en-US.ts +128 -0
  323. package/locale/lang/th-TH.ts +127 -0
  324. package/locale/lang/vi-VN.ts +89 -0
  325. package/locale/lang/zh-CN.ts +127 -0
  326. package/locale/lang/zh-HK.ts +84 -0
  327. package/locale/lang/zh-TW.ts +84 -0
  328. package/package.json +20 -0
@@ -0,0 +1,285 @@
1
+ @import './../common/abstracts/_mixin';
2
+ @import './../common/abstracts/variable';
3
+
4
+ .wot-theme-dark {
5
+ @include b(checkbox) {
6
+ @include e(shape) {
7
+ color: $-checkbox-check-color;
8
+ background: transparent;
9
+ border-color: $-checkbox-border-color;
10
+ }
11
+
12
+ @include e(label) {
13
+ color: $-dark-color;
14
+ }
15
+
16
+ @include when(disabled) {
17
+ .wd-checkbox__shape {
18
+ background: $-dark-background4;
19
+ border-color: $-dark-color-gray;
20
+ }
21
+
22
+ .wd-checkbox__label {
23
+ color: $-dark-color-gray;
24
+ }
25
+
26
+ :deep(.wd-checkbox__check) {
27
+ color: $-dark-color-gray;
28
+ }
29
+
30
+ @include when(checked) {
31
+ .wd-checkbox__shape {
32
+ color: $-dark-color-gray;
33
+ }
34
+
35
+ .wd-checkbox__label {
36
+ color: $-dark-color-gray;
37
+ }
38
+ }
39
+
40
+ @include when(button) {
41
+ .wd-checkbox__label {
42
+ color: $-dark-color-gray;
43
+ background: #3a3a3c;
44
+ border-color: #c8c9cc;
45
+ }
46
+
47
+ @include when(checked) {
48
+ .wd-checkbox__label {
49
+ color: #c8c9cc;
50
+ background: #3a3a3c;
51
+ border-color: #c8c9cc;
52
+ }
53
+ }
54
+ }
55
+ }
56
+
57
+ @include when(button) {
58
+ .wd-checkbox__label {
59
+ background-color: $-dark-background;
60
+ }
61
+
62
+ @include when(checked) {
63
+ .wd-checkbox__label {
64
+ background-color: $-dark-background2;
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+
71
+ @include b(checkbox) {
72
+ display: block;
73
+ margin-bottom: $-checkbox-margin;
74
+ font-size: 0;
75
+ -webkit-tap-highlight-color: transparent;
76
+ line-height: 1.2;
77
+
78
+ @include when(last-child) {
79
+ margin-bottom: 0;
80
+ }
81
+
82
+ @include e(shape) {
83
+ position: relative;
84
+ box-sizing: border-box;
85
+ display: inline-block;
86
+ width: $-checkbox-size;
87
+ height: $-checkbox-size;
88
+ color: $-checkbox-check-color;
89
+ vertical-align: middle;
90
+ background: $-checkbox-bg;
91
+ border: 2px solid $-checkbox-border-color;
92
+ border-radius: 50%;
93
+ transition: background 0.2s;
94
+
95
+ @include when(square) {
96
+ border-radius: $-checkbox-square-radius;
97
+ }
98
+ }
99
+
100
+ @include e(input) {
101
+ position: absolute;
102
+ width: 0;
103
+ height: 0;
104
+ margin: 0;
105
+ opacity: 0;
106
+ }
107
+
108
+ @include edeep(btn-check) {
109
+ display: inline-block;
110
+ margin-right: 4px;
111
+ font-size: $-checkbox-icon-size;
112
+ vertical-align: middle;
113
+ }
114
+
115
+ @include e(txt) {
116
+ display: inline-block;
117
+ line-height: 20px;
118
+ vertical-align: middle;
119
+ @include lineEllipsis;
120
+ }
121
+
122
+ @include e(label) {
123
+ position: relative;
124
+ display: inline-block;
125
+ margin-left: $-checkbox-label-margin;
126
+ font-size: $-checkbox-label-fs;
127
+ color: $-checkbox-label-color;
128
+ vertical-align: middle;
129
+ }
130
+
131
+ @include edeep(check) {
132
+ font-size: $-checkbox-icon-size;
133
+ color: $-checkbox-check-color;
134
+ opacity: 0;
135
+ transition: opacity 0.2s;
136
+ }
137
+
138
+ @include when(checked) {
139
+ .wd-checkbox__shape {
140
+ color: $-checkbox-checked-color;
141
+ background: currentColor;
142
+ border-color: currentColor;
143
+ }
144
+
145
+ :deep(.wd-checkbox__check) {
146
+ position: absolute;
147
+ top: 50%;
148
+ left: 50%;
149
+ opacity: 1;
150
+ transform: translate(-50%, -50%);
151
+ }
152
+ }
153
+
154
+ @include when(button) {
155
+ display: inline-block;
156
+ margin-right: $-checkbox-margin;
157
+ margin-bottom: 0;
158
+ font-size: $-checkbox-button-font-size;
159
+ vertical-align: top;
160
+
161
+ @include when(last-child) {
162
+ margin-right: 0;
163
+ }
164
+
165
+ .wd-checkbox__shape {
166
+ width: 0;
167
+ height: 0;
168
+ overflow: hidden;
169
+ border: none;
170
+ opacity: 0;
171
+ }
172
+
173
+ .wd-checkbox__label {
174
+ box-sizing: border-box;
175
+ display: inline-flex;
176
+ flex-direction: row;
177
+ align-items: center;
178
+ justify-content: center;
179
+ min-width: $-checkbox-button-min-width;
180
+ height: $-checkbox-button-height;
181
+ padding: 5px 15px;
182
+ margin-left: 0;
183
+ font-size: $-checkbox-button-font-size;
184
+ background-color: $-checkbox-button-bg;
185
+ border: 1px solid $-checkbox-button-border;
186
+ border-radius: $-checkbox-button-radius;
187
+ transition:
188
+ color 0.2s,
189
+ border 0.2s;
190
+ }
191
+
192
+ @include when(checked) {
193
+ .wd-checkbox__label {
194
+ color: $-checkbox-checked-color;
195
+ background-color: $-checkbox-bg;
196
+ border-color: $-checkbox-checked-color;
197
+ border-color: currentColor;
198
+ }
199
+ }
200
+ }
201
+
202
+ @include when(inline) {
203
+ display: inline-block;
204
+ margin-right: $-checkbox-margin;
205
+ margin-bottom: 0;
206
+
207
+ @include when(last-child) {
208
+ margin-right: 0;
209
+ }
210
+ }
211
+
212
+ @include when(disabled) {
213
+ .wd-checkbox__shape {
214
+ background: $-checkbox-disabled-check-bg;
215
+ border-color: $-checkbox-border-color;
216
+ }
217
+
218
+ .wd-checkbox__label {
219
+ color: $-checkbox-disabled-label-color;
220
+ }
221
+
222
+ @include when(checked) {
223
+ .wd-checkbox__shape {
224
+ color: $-checkbox-disabled-check-color;
225
+ }
226
+
227
+ .wd-checkbox__label {
228
+ color: $-checkbox-disabled-label-color;
229
+ }
230
+ }
231
+
232
+ @include when(button) {
233
+ .wd-checkbox__label {
234
+ color: $-checkbox-disabled-label-color;
235
+ background: $-checkbox-disabled-color;
236
+ border-color: $-checkbox-button-border;
237
+ }
238
+
239
+ @include when(checked) {
240
+ .wd-checkbox__label {
241
+ border-color: $-checkbox-button-disabled-border;
242
+ }
243
+ }
244
+ }
245
+ }
246
+
247
+ // 以下内容用于解决父子组件样式隔离的问题 —— START
248
+ @include when(cell-box) {
249
+ padding: 13px 15px;
250
+ margin: 0;
251
+
252
+ @include when(large) {
253
+ padding: 14px 15px;
254
+ }
255
+ }
256
+
257
+ @include when(button-box) {
258
+ box-sizing: border-box;
259
+ display: inline-flex;
260
+ width: 33.3333%;
261
+ padding: 12px 12px 0 0;
262
+
263
+ .wd-checkbox__label {
264
+ width: 100%;
265
+ }
266
+
267
+ &:last-child::after {
268
+ display: table;
269
+ clear: both;
270
+ content: '';
271
+ }
272
+ }
273
+
274
+ @include when(large) {
275
+ .wd-checkbox__shape {
276
+ width: $-checkbox-large-size;
277
+ height: $-checkbox-large-size;
278
+ font-size: $-checkbox-large-size;
279
+ }
280
+
281
+ .wd-checkbox__label {
282
+ font-size: $-checkbox-large-label-fs;
283
+ }
284
+ }
285
+ }
@@ -0,0 +1,68 @@
1
+ import type { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue'
2
+ import { baseProps, makeStringProp } from '../common/props'
3
+
4
+ export type CheckShape = 'circle' | 'square' | 'button'
5
+
6
+ export const checkboxProps = {
7
+ ...baseProps,
8
+ customLabelClass: makeStringProp(''),
9
+ customShapeClass: makeStringProp(''),
10
+ /**
11
+ * 单选框选中时的值
12
+ */
13
+ modelValue: {
14
+ type: [String, Number, Boolean],
15
+ required: true,
16
+ default: false,
17
+ },
18
+ /**
19
+ * 单选框形状,可选值:circle / square / button
20
+ */
21
+ shape: {
22
+ type: String as PropType<CheckShape>,
23
+ },
24
+ /**
25
+ * 选中的颜色
26
+ */
27
+ checkedColor: String,
28
+ /**
29
+ * 禁用
30
+ */
31
+ disabled: {
32
+ type: [Boolean, null] as PropType<boolean | null>,
33
+ default: null,
34
+ },
35
+ /**
36
+ * 选中值,在 checkbox-group 中使用无效,需同 false-value 一块使用
37
+ */
38
+ trueValue: {
39
+ type: [String, Number, Boolean],
40
+ default: true,
41
+ },
42
+ /**
43
+ * 非选中时的值,在 checkbox-group 中使用无效,需同 true-value 一块使用
44
+ */
45
+ falseValue: {
46
+ type: [String, Number, Boolean],
47
+ default: false,
48
+ },
49
+ /**
50
+ * 设置大小,可选值:large
51
+ */
52
+ size: String,
53
+ /**
54
+ * 文字位置最大宽度
55
+ */
56
+ maxWidth: String,
57
+ }
58
+
59
+ export type CheckboxProps = ExtractPropTypes<typeof checkboxProps>
60
+
61
+ export type CheckboxExpose = {
62
+ /**
63
+ * 切换当前选中状态
64
+ */
65
+ toggle: () => void
66
+ }
67
+
68
+ export type CheckboxInstance = ComponentPublicInstance<CheckboxProps, CheckboxExpose>
@@ -0,0 +1,185 @@
1
+ <template>
2
+ <view
3
+ :class="`wd-checkbox ${innerCell ? 'is-cell-box' : ''} ${innerShape === 'button' ? 'is-button-box' : ''} ${isChecked ? 'is-checked' : ''} ${
4
+ isFirst ? 'is-first-child' : ''
5
+ } ${isLast ? 'is-last-child' : ''} ${innerInline ? 'is-inline' : ''} ${innerShape === 'button' ? 'is-button' : ''} ${
6
+ innerDisabled ? 'is-disabled' : ''
7
+ } ${innerSize ? 'is-' + innerSize : ''} ${customClass}`"
8
+ :style="customStyle"
9
+ @click="toggle"
10
+ >
11
+ <!--shape为button时,移除wd-checkbox__shape,只保留wd-checkbox__label-->
12
+ <view
13
+ v-if="innerShape !== 'button'"
14
+ :class="`wd-checkbox__shape ${innerShape === 'square' ? 'is-square' : ''} ${customShapeClass}`"
15
+ :style="isChecked && !innerDisabled && innerCheckedColor ? 'color :' + innerCheckedColor : ''"
16
+ >
17
+ <wd-icon custom-class="wd-checkbox__check" name="check-bold" />
18
+ </view>
19
+ <!--shape为button时只保留wd-checkbox__label-->
20
+ <view
21
+ :class="`wd-checkbox__label ${customLabelClass}`"
22
+ :style="
23
+ isChecked && innerShape === 'button' && !innerDisabled && innerCheckedColor
24
+ ? 'color:' + innerCheckedColor
25
+ : ''
26
+ "
27
+ >
28
+ <!--button选中时展示的icon-->
29
+ <wd-icon
30
+ v-if="innerShape === 'button' && isChecked"
31
+ custom-class="wd-checkbox__btn-check"
32
+ name="check-bold"
33
+ />
34
+ <!--文案-->
35
+ <view class="wd-checkbox__txt" :style="maxWidth ? 'max-width:' + maxWidth : ''">
36
+ <slot></slot>
37
+ </view>
38
+ </view>
39
+ </view>
40
+ </template>
41
+
42
+ <script lang="ts">
43
+ export default {
44
+ name: 'wd-checkbox',
45
+ options: {
46
+ addGlobalClass: true,
47
+ virtualHost: true,
48
+ styleIsolation: 'shared',
49
+ },
50
+ }
51
+ </script>
52
+
53
+ <script lang="ts" setup>
54
+ import { computed, getCurrentInstance, onBeforeMount, watch } from 'vue'
55
+ import { useParent } from '../composables/useParent'
56
+ import { CHECKBOX_GROUP_KEY } from '../wd-checkbox-group/types'
57
+ import { getPropByPath, isDef } from '../common/util'
58
+ import { checkboxProps, type CheckboxExpose } from './types'
59
+
60
+ const props = defineProps(checkboxProps)
61
+ const emit = defineEmits(['change', 'update:modelValue'])
62
+
63
+ defineExpose<CheckboxExpose>({
64
+ toggle,
65
+ })
66
+
67
+ const { parent: checkboxGroup, index } = useParent(CHECKBOX_GROUP_KEY)
68
+
69
+ const isChecked = computed(() => {
70
+ if (checkboxGroup) {
71
+ return checkboxGroup.props.modelValue.indexOf(props.modelValue) > -1
72
+ } else {
73
+ return props.modelValue === props.trueValue
74
+ }
75
+ }) // 是否被选中
76
+
77
+ const isFirst = computed(() => {
78
+ return index.value === 0
79
+ })
80
+
81
+ const isLast = computed(() => {
82
+ const children = isDef(checkboxGroup) ? checkboxGroup.children : []
83
+ return index.value === children.length - 1
84
+ })
85
+ const { proxy } = getCurrentInstance() as any
86
+
87
+ watch(
88
+ () => props.modelValue,
89
+ () => {
90
+ // 组合使用走这个逻辑
91
+ if (checkboxGroup) {
92
+ checkName()
93
+ }
94
+ },
95
+ )
96
+
97
+ watch(
98
+ () => props.shape,
99
+ (newValue) => {
100
+ const type = ['circle', 'square', 'button']
101
+ if (isDef(newValue) && type.indexOf(newValue) === -1)
102
+ console.error(`shape must be one of ${type.toString()}`)
103
+ },
104
+ )
105
+
106
+ const innerShape = computed(() => {
107
+ return props.shape || getPropByPath(checkboxGroup, 'props.shape') || 'circle'
108
+ })
109
+
110
+ const innerCheckedColor = computed(() => {
111
+ return props.checkedColor || getPropByPath(checkboxGroup, 'props.checkedColor')
112
+ })
113
+
114
+ const innerDisabled = computed(() => {
115
+ if (!checkboxGroup) {
116
+ return props.disabled
117
+ }
118
+ const { max, min, modelValue, disabled } = checkboxGroup.props
119
+ if (
120
+ (max && modelValue.length >= max && !isChecked.value) ||
121
+ (min && modelValue.length <= min && isChecked.value) ||
122
+ props.disabled === true ||
123
+ (disabled && props.disabled === null)
124
+ ) {
125
+ return true
126
+ }
127
+
128
+ return props.disabled
129
+ })
130
+
131
+ const innerInline = computed(() => {
132
+ return getPropByPath(checkboxGroup, 'props.inline') || false
133
+ })
134
+
135
+ const innerCell = computed(() => {
136
+ return getPropByPath(checkboxGroup, 'props.cell') || false
137
+ })
138
+
139
+ const innerSize = computed(() => {
140
+ return props.size || getPropByPath(checkboxGroup, 'props.size')
141
+ })
142
+
143
+ onBeforeMount(() => {
144
+ // eslint-disable-next-line quotes
145
+ if (props.modelValue === null) console.error("checkbox's value must be set")
146
+ })
147
+
148
+ /**
149
+ * @description 检测checkbox绑定的value是否和其它checkbox的value冲突
150
+ * @param {Object} self 自身
151
+ * @param myName 自己的标识符
152
+ */
153
+ function checkName() {
154
+ checkboxGroup &&
155
+ checkboxGroup.children &&
156
+ checkboxGroup.children.forEach((child: any) => {
157
+ if (child.$.uid !== proxy.$.uid && child.modelValue === props.modelValue) {
158
+ console.error(`The checkbox's bound value: ${props.modelValue} has been used`)
159
+ }
160
+ })
161
+ }
162
+ /**
163
+ * @description 点击checkbox的Event handle
164
+ */
165
+ function toggle() {
166
+ if (innerDisabled.value) return
167
+ // 复选框单独使用时点击反选,并且在checkbox上触发change事件
168
+ if (checkboxGroup) {
169
+ emit('change', {
170
+ value: !isChecked.value,
171
+ })
172
+ checkboxGroup.changeSelectState(props.modelValue)
173
+ } else {
174
+ const newVal = props.modelValue === props.trueValue ? props.falseValue : props.trueValue
175
+ emit('update:modelValue', newVal)
176
+ emit('change', {
177
+ value: newVal,
178
+ })
179
+ }
180
+ }
181
+ </script>
182
+
183
+ <style lang="scss" scoped>
184
+ @import './index';
185
+ </style>
@@ -0,0 +1,20 @@
1
+ @import './../common/abstracts/_mixin';
2
+ @import './../common/abstracts/variable';
3
+
4
+ .wot-theme-dark {
5
+ @include b(checkbox-group) {
6
+ background-color: $-dark-background2;
7
+ }
8
+ }
9
+ @include b(checkbox-group) {
10
+ background-color: $-checkbox-bg;
11
+
12
+ // 上下20px 左右15px 内部间隔12px
13
+ @include when(button) {
14
+ box-sizing: border-box;
15
+ width: 100%;
16
+ height: auto;
17
+ padding: 8px 3px 20px 15px;
18
+ overflow: hidden;
19
+ }
20
+ }
@@ -0,0 +1,59 @@
1
+ import { type ExtractPropTypes, type InjectionKey, type PropType } from 'vue'
2
+ import type { CheckShape } from '../wd-checkbox/types'
3
+ import { baseProps, makeBooleanProp, makeNumberProp, makeStringProp } from '../common/props'
4
+
5
+ export type RequiredModelValue = {
6
+ modelValue: Array<string | number | boolean>
7
+ }
8
+
9
+ export type checkboxGroupProvide = {
10
+ props: Partial<Omit<CheckboxGroupProps, 'modelValue'>> & RequiredModelValue
11
+ changeSelectState: (value: string | number | boolean) => void
12
+ }
13
+
14
+ export const CHECKBOX_GROUP_KEY: InjectionKey<checkboxGroupProvide> = Symbol('wd-checkbox-group')
15
+
16
+ export const checkboxGroupProps = {
17
+ ...baseProps,
18
+ /**
19
+ * 绑定值
20
+ */
21
+ modelValue: {
22
+ type: Array as PropType<Array<string | number | boolean>>,
23
+ default: () => [],
24
+ },
25
+ /**
26
+ * 表单模式
27
+ */
28
+ cell: makeBooleanProp(false),
29
+ /**
30
+ * 单选框形状,可选值:circle / square / button
31
+ */
32
+ shape: makeStringProp<CheckShape>('circle'),
33
+ /**
34
+ * 选中的颜色
35
+ */
36
+ checkedColor: String,
37
+ /**
38
+ * 禁用
39
+ */
40
+ disabled: makeBooleanProp(false),
41
+ /**
42
+ * 最小选中的数量
43
+ */
44
+ min: makeNumberProp(0),
45
+ /**
46
+ * 最大选中的数量,0 为无限数量,默认为 0
47
+ */
48
+ max: makeNumberProp(0),
49
+ /**
50
+ * 同行展示
51
+ */
52
+ inline: makeBooleanProp(false),
53
+ /**
54
+ * 设置大小,可选值:large
55
+ */
56
+ size: String,
57
+ }
58
+
59
+ export type CheckboxGroupProps = ExtractPropTypes<typeof checkboxGroupProps>
@@ -0,0 +1,103 @@
1
+ <template>
2
+ <view
3
+ :class="`wd-checkbox-group ${shape === 'button' && cell ? 'is-button' : ''} ${customClass}`"
4
+ :style="customStyle"
5
+ >
6
+ <slot />
7
+ </view>
8
+ </template>
9
+ <script lang="ts">
10
+ export default {
11
+ name: 'wd-checkbox-group',
12
+ options: {
13
+ addGlobalClass: true,
14
+ virtualHost: true,
15
+ styleIsolation: 'shared',
16
+ },
17
+ }
18
+ </script>
19
+
20
+ <script lang="ts" setup>
21
+ import { watch } from 'vue'
22
+ import { checkNumRange, deepClone } from '../common/util'
23
+ import { useChildren } from '../composables/useChildren'
24
+ import { CHECKBOX_GROUP_KEY, checkboxGroupProps } from './types'
25
+
26
+ const props = defineProps(checkboxGroupProps)
27
+ const emit = defineEmits(['change', 'update:modelValue'])
28
+
29
+ const { linkChildren } = useChildren(CHECKBOX_GROUP_KEY)
30
+
31
+ linkChildren({ props, changeSelectState })
32
+
33
+ watch(
34
+ () => props.modelValue,
35
+ (newValue) => {
36
+ // 传入的value数组中包括重复的元素,这种情况非法。
37
+ if (new Set(newValue).size !== newValue.length) {
38
+ // eslint-disable-next-line quotes
39
+ console.error("checkboxGroup's bound value includes same value")
40
+ }
41
+ if (newValue.length < props.min) {
42
+ // eslint-disable-next-line quotes
43
+ console.error("checkboxGroup's bound value's length can't be less than min")
44
+ }
45
+ if (props.max !== 0 && newValue.length > props.max) {
46
+ // eslint-disable-next-line quotes
47
+ console.error("checkboxGroup's bound value's length can't be large than max")
48
+ }
49
+ // 每次value变化都会触发重新匹配选中项
50
+ },
51
+ { deep: true, immediate: true },
52
+ )
53
+
54
+ watch(
55
+ () => props.shape,
56
+ (newValue) => {
57
+ const type = ['circle', 'square', 'button']
58
+ if (type.indexOf(newValue) === -1) console.error(`shape must be one of ${type.toString()}`)
59
+ },
60
+ { deep: true, immediate: true },
61
+ )
62
+
63
+ watch(
64
+ () => props.min,
65
+ (newValue) => {
66
+ checkNumRange(newValue, 'min')
67
+ },
68
+ { deep: true, immediate: true },
69
+ )
70
+
71
+ watch(
72
+ () => props.max,
73
+ (newValue) => {
74
+ checkNumRange(newValue, 'max')
75
+ },
76
+ { deep: true, immediate: true },
77
+ )
78
+
79
+ /**
80
+ * @description 子节点通知父节点修改子节点选中状态
81
+ * @param {any} value 子组件的标识符
82
+ */
83
+ function changeSelectState(value: string | number | boolean) {
84
+ const temp: (string | number | boolean)[] = deepClone(props.modelValue)
85
+ const index = temp.indexOf(value)
86
+ if (index > -1) {
87
+ // 已经选中,则从 value 列表中删除子节点的标识符。
88
+ temp.splice(index, 1)
89
+ } else {
90
+ // 之前未选中,则现在把加子节点的标识符加到 value 列表中。
91
+ temp.push(value)
92
+ }
93
+ emit('update:modelValue', temp)
94
+
95
+ emit('change', {
96
+ value: temp,
97
+ })
98
+ }
99
+ </script>
100
+
101
+ <style lang="scss" scoped>
102
+ @import './index';
103
+ </style>