@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,23 @@
1
+ @import './../common/abstracts/_mixin';
2
+ @import './../common/abstracts/variable';
3
+
4
+ .wot-theme-dark {
5
+ @include b(radio-group) {
6
+ background-color: $-dark-background2;
7
+ }
8
+ }
9
+
10
+ @include b(radio-group) {
11
+ font-size: 0;
12
+ background-color: $-radio-bg;
13
+
14
+ // 上下20px 左右15px 内部间隔12px
15
+ @include when(button) {
16
+ box-sizing: border-box;
17
+ width: 100%;
18
+ height: 100%;
19
+ height: auto;
20
+ padding: 8px 3px 20px 15px;
21
+ overflow: hidden;
22
+ }
23
+ }
@@ -0,0 +1,36 @@
1
+ import { type InjectionKey } from 'vue'
2
+ import type { RadioShape } from '../wd-radio/types'
3
+ import { baseProps, makeBooleanProp, makeStringProp } from '../common/props'
4
+
5
+ export type RadioGroupProvide = {
6
+ props: {
7
+ modelValue?: string | number | boolean
8
+ shape?: RadioShape
9
+ checkedColor?: string
10
+ disabled?: boolean
11
+ cell?: boolean
12
+ size?: string
13
+ inline?: boolean
14
+ }
15
+ updateValue: (value: string | number | boolean) => void
16
+ }
17
+
18
+ export const RADIO_GROUP_KEY: InjectionKey<RadioGroupProvide> = Symbol('wd-radio-group')
19
+
20
+ export const radioGroupProps = {
21
+ ...baseProps,
22
+ /** 会自动选中value对应的单选框 */
23
+ modelValue: [String, Number, Boolean],
24
+ /** 单选框形状,可选值为 dot / button / check,默认为 check */
25
+ shape: makeStringProp<RadioShape>('check'),
26
+ /** 选中的颜色,默认为 #4D80F0 */
27
+ checkedColor: String,
28
+ /** 是否禁用,默认为 false */
29
+ disabled: makeBooleanProp(false),
30
+ /** 表单模式,默认为 false */
31
+ cell: makeBooleanProp(false),
32
+ /** 设置大小,默认为空 */
33
+ size: makeStringProp(''),
34
+ /** 同行展示,默认为 false */
35
+ inline: makeBooleanProp(false),
36
+ }
@@ -0,0 +1,54 @@
1
+ <template>
2
+ <view
3
+ :class="`wd-radio-group ${customClass} ${cell && shape === 'button' ? 'is-button' : ''}`"
4
+ :style="customStyle"
5
+ >
6
+ <slot />
7
+ </view>
8
+ </template>
9
+ <script lang="ts">
10
+ export default {
11
+ name: 'wd-radio-group',
12
+ options: {
13
+ virtualHost: true,
14
+ addGlobalClass: true,
15
+ styleIsolation: 'shared',
16
+ },
17
+ }
18
+ </script>
19
+
20
+ <script lang="ts" setup>
21
+ import { watch } from 'vue'
22
+ import { useChildren } from '../composables/useChildren'
23
+ import { RADIO_GROUP_KEY, radioGroupProps } from './types'
24
+
25
+ const props = defineProps(radioGroupProps)
26
+ const emit = defineEmits(['change', 'update:modelValue'])
27
+
28
+ const { linkChildren, children } = useChildren(RADIO_GROUP_KEY)
29
+
30
+ linkChildren({ props, updateValue })
31
+
32
+ watch(
33
+ () => props.shape,
34
+ (newValue) => {
35
+ // type: 'dot', 'button', 'check'
36
+ const type = ['check', 'dot', 'button']
37
+ if (type.indexOf(newValue) === -1) console.error(`shape must be one of ${type.toString()}`)
38
+ },
39
+ { deep: true, immediate: true },
40
+ )
41
+
42
+ /**
43
+ * @description 处理radio子节点通知
44
+ */
45
+ function updateValue(value: string | number | boolean) {
46
+ emit('update:modelValue', value)
47
+ emit('change', {
48
+ value,
49
+ })
50
+ }
51
+ </script>
52
+ <style lang="scss" scoped>
53
+ @import './index';
54
+ </style>
@@ -0,0 +1,24 @@
1
+ @import './../common/abstracts/_mixin';
2
+ @import './../common/abstracts/variable';
3
+
4
+ @include b(rate) {
5
+ display: inline-block;
6
+ line-height: 1;
7
+ vertical-align: middle;
8
+
9
+ @include e(item) {
10
+ position: relative;
11
+ display: inline-block;
12
+ }
13
+ @include e(item-star) {
14
+ display: inline-block;
15
+ vertical-align: top;
16
+
17
+ @include m(active) {
18
+ position: absolute;
19
+ top: 0;
20
+ left: 0;
21
+ overflow: hidden;
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,91 @@
1
+ import type { PropType } from 'vue'
2
+ import { baseProps, makeBooleanProp, makeNumberProp, makeStringProp } from '../common/props'
3
+
4
+ export const rateProps = {
5
+ ...baseProps,
6
+
7
+ /**
8
+ * 评分最大值
9
+ * 类型: number
10
+ * 默认值: 5
11
+ */
12
+ num: makeNumberProp(5),
13
+
14
+ /**
15
+ * 当前分数,使用v-model进行双向绑定
16
+ * 类型: string | number | null
17
+ * 默认值: null
18
+ */
19
+ modelValue: {
20
+ type: [String, Number, null] as PropType<string | number | null>,
21
+ default: null,
22
+ },
23
+
24
+ /**
25
+ * 是否只读
26
+ * 类型: boolean
27
+ * 默认值: false
28
+ */
29
+ readonly: makeBooleanProp(false),
30
+
31
+ /**
32
+ * 图标大小
33
+ * 类型: string
34
+ * 默认值: '16px'
35
+ */
36
+ size: makeStringProp('16px'),
37
+
38
+ /**
39
+ * 图标间距
40
+ * 类型: string
41
+ * 默认值: '4px'
42
+ */
43
+ space: makeStringProp('4px'),
44
+
45
+ /**
46
+ * 未选中的图标颜色
47
+ * 类型: string
48
+ * 默认值: '#E8E8E8'
49
+ */
50
+ color: makeStringProp('#E8E8E8'),
51
+
52
+ /**
53
+ * 选中的图标颜色,支持传颜色数组(用于分段颜色)
54
+ * 类型: string | Array<string>
55
+ * 默认值: 'linear-gradient(180deg, rgba(255,238,0,1) 0%,rgba(250,176,21,1) 100%)'
56
+ */
57
+ activeColor: {
58
+ type: [String, Array] as PropType<string | Array<string>>,
59
+ default: 'linear-gradient(180deg, rgba(255,238,0,1) 0%,rgba(250,176,21,1) 100%)',
60
+ },
61
+
62
+ /**
63
+ * 未选中的图标类名
64
+ * 类型: string
65
+ * 默认值: 'star-on'
66
+ */
67
+ icon: makeStringProp('star-on'),
68
+
69
+ /**
70
+ * 选中的图标类名
71
+ * 类型: string
72
+ * 默认值: 'star-on'
73
+ */
74
+ activeIcon: makeStringProp('star-on'),
75
+
76
+ /**
77
+ * 是否禁用
78
+ * 类型: boolean
79
+ * 默认值: false
80
+ */
81
+ disabled: makeBooleanProp(false),
82
+
83
+ /**
84
+ * 禁用的图标颜色
85
+ * 类型: string
86
+ * 默认值: 'linear-gradient(315deg, rgba(177,177,177,1) 0%,rgba(199,199,199,1) 100%)'
87
+ */
88
+ disabledColor: makeStringProp(
89
+ 'linear-gradient(315deg, rgba(177,177,177,1) 0%,rgba(199,199,199,1) 100%)',
90
+ ),
91
+ }
@@ -0,0 +1,131 @@
1
+ <template>
2
+ <view :class="`wd-rate ${customClass}`" :style="customStyle">
3
+ <view
4
+ v-for="(rate, index) in rateList"
5
+ :key="index"
6
+ :data-index="index"
7
+ :style="{ 'margin-right': index == rateList.length - 1 ? 0 : space }"
8
+ class="wd-rate__item"
9
+ @click="changeRate(index)"
10
+ >
11
+ <view class="wd-rate__item-star" :style="{ width: size, height: size }">
12
+ <wd-icon :name="icon" :size="size" :custom-style="iconStyle" />
13
+ </view>
14
+ <view
15
+ class="wd-rate__item-star wd-rate__item-star--active"
16
+ :style="{ width: rate, height: size }"
17
+ >
18
+ <wd-icon :name="activeIcon" :size="size" :custom-style="iconActiveStyle" />
19
+ </view>
20
+ </view>
21
+ </view>
22
+ </template>
23
+
24
+ <script lang="ts">
25
+ export default {
26
+ name: 'wd-rate',
27
+ options: {
28
+ addGlobalClass: true,
29
+ virtualHost: true,
30
+ styleIsolation: 'shared',
31
+ },
32
+ }
33
+ </script>
34
+ <script lang="ts" setup>
35
+ import { computed, ref, watch } from 'vue'
36
+ import { rateProps } from './types'
37
+
38
+ const props = defineProps(rateProps)
39
+ const emit = defineEmits(['update:modelValue', 'change'])
40
+
41
+ const rateList = ref<Array<string>>([])
42
+ const activeValue = ref<string>('')
43
+
44
+ const iconStyle = computed(() => {
45
+ return `background:${props.color}; -webkit-background-clip: text; color: transparent`
46
+ })
47
+
48
+ const iconActiveStyle = computed(() => {
49
+ return `background:${props.disabled ? props.disabledColor : activeValue.value}; -webkit-background-clip: text; color: transparent`
50
+ })
51
+
52
+ watch(
53
+ () => props.activeColor,
54
+ (newVal) => {
55
+ if (Array.isArray(newVal) && !newVal.length) {
56
+ console.error('activeColor cannot be an empty array')
57
+ }
58
+ computeActiveValue()
59
+ },
60
+ {
61
+ immediate: true,
62
+ deep: true,
63
+ },
64
+ )
65
+
66
+ watch(
67
+ [() => props.num, () => props.modelValue],
68
+ () => {
69
+ computeRateList()
70
+ },
71
+ {
72
+ immediate: true,
73
+ deep: true,
74
+ },
75
+ )
76
+
77
+ /**
78
+ * @description 计算当前应当展示的rate数量
79
+ */
80
+ function computeRateList() {
81
+ const { modelValue, num } = props
82
+ // value和num都准备好才能计算
83
+ if (modelValue === null || !num) return
84
+ if (typeof modelValue !== 'number') {
85
+ console.error('[Wot Design] error(wd-rate): the value of wd-rate should be a number')
86
+ return
87
+ }
88
+ const tempRateList: string[] = []
89
+ const fullLength = Math.ceil(modelValue) - 1
90
+ for (let i = 0; i < num; i++) {
91
+ if (i < fullLength) {
92
+ tempRateList.push('100%')
93
+ } else if (i === fullLength) {
94
+ const rate = modelValue - fullLength > 0.5 ? 1 : 0.5
95
+ tempRateList.push(rate * 100 + '%')
96
+ } else {
97
+ tempRateList.push('0')
98
+ }
99
+ }
100
+ rateList.value = tempRateList
101
+ computeActiveValue()
102
+ }
103
+ /**
104
+ * @description 计算当前应当展示的rate颜色
105
+ */
106
+ function computeActiveValue() {
107
+ const { activeColor, modelValue, num } = props
108
+ let tempActiveValue: string = ''
109
+ if (Array.isArray(activeColor) && activeColor.length) {
110
+ tempActiveValue =
111
+ Number(modelValue) <= num * 0.6 || !activeColor[1] ? activeColor[0] : activeColor[1]
112
+ } else {
113
+ tempActiveValue = activeColor as string
114
+ }
115
+ activeValue.value = tempActiveValue
116
+ }
117
+ /**
118
+ * @description 点击icon触发组件的change事件
119
+ * @param Event
120
+ */
121
+ function changeRate(index: number) {
122
+ if (props.readonly || props.disabled) return
123
+ emit('update:modelValue', index + 1)
124
+ emit('change', {
125
+ value: index + 1,
126
+ })
127
+ }
128
+ </script>
129
+ <style lang="scss" scoped>
130
+ @import './index';
131
+ </style>
@@ -0,0 +1,26 @@
1
+ @import '../common/abstracts/variable';
2
+ @import '../common/abstracts/mixin';
3
+
4
+ @include b(resize) {
5
+ @include e(container) {
6
+ position: absolute;
7
+ min-width: 1px;
8
+ min-height: 1px;
9
+ }
10
+
11
+ @include e(wrapper) {
12
+ position: absolute;
13
+ top: 0;
14
+ right: 0;
15
+ bottom: 0;
16
+ left: 0;
17
+ z-index: -9999;
18
+ overflow: hidden;
19
+ visibility: hidden;
20
+
21
+ @include m(placeholder) {
22
+ transition: 0s;
23
+ animation: none;
24
+ }
25
+ }
26
+ }
@@ -0,0 +1,6 @@
1
+ import { baseProps, makeStringProp } from '../common/props'
2
+
3
+ export const resizeProps = {
4
+ ...baseProps,
5
+ customContainerClass: makeStringProp(''),
6
+ }
@@ -0,0 +1,155 @@
1
+ <template>
2
+ <view :class="`wd-resize ${customClass}`" :style="rootStyle">
3
+ <!--插槽需要脱离父容器文档流,防止父容器固宽固高,进而导致插槽大小被被父容器限制-->
4
+ <view :id="resizeId" :class="`wd-resize__container ${customContainerClass}`">
5
+ <!--被监听的插槽-->
6
+ <slot />
7
+ <!--监听插槽变大-->
8
+ <scroll-view
9
+ class="wd-resize__wrapper"
10
+ :scroll-y="true"
11
+ :scroll-top="expandScrollTop"
12
+ :scroll-x="true"
13
+ :scroll-left="expandScrollLeft"
14
+ @scroll="onScrollHandler"
15
+ >
16
+ <view
17
+ class="wd-resize__wrapper--placeholder"
18
+ style="height: 100000px; width: 100000px"
19
+ ></view>
20
+ </scroll-view>
21
+ <!--监听插槽变小-->
22
+ <scroll-view
23
+ class="wd-resize__wrapper"
24
+ :scroll-y="true"
25
+ :scroll-top="shrinkScrollTop"
26
+ :scroll-x="true"
27
+ :scroll-left="shrinkScrollLeft"
28
+ @scroll="onScrollHandler"
29
+ >
30
+ <view class="wd-resize__wrapper--placeholder" style="height: 250%; width: 250%"></view>
31
+ </scroll-view>
32
+ </view>
33
+ </view>
34
+ </template>
35
+
36
+ <script lang="ts">
37
+ export default {
38
+ name: 'wd-resize',
39
+ options: {
40
+ virtualHost: true,
41
+ addGlobalClass: true,
42
+ styleIsolation: 'shared',
43
+ },
44
+ }
45
+ </script>
46
+
47
+ <script lang="ts" setup>
48
+ import { computed, getCurrentInstance, onMounted, ref } from 'vue'
49
+ import { addUnit, objToStyle, uuid } from '../common/util'
50
+ import { resizeProps } from './types'
51
+
52
+ const props = defineProps(resizeProps)
53
+ const emit = defineEmits(['resize'])
54
+
55
+ const expandScrollTop = ref<number>(0)
56
+ const shrinkScrollTop = ref<number>(0)
57
+ const expandScrollLeft = ref<number>(0)
58
+ const shrinkScrollLeft = ref<number>(0)
59
+ const height = ref<number>(0)
60
+ const width = ref<number>(0)
61
+ const scrollEventCount = ref<number>(0)
62
+
63
+ const rootStyle = computed(() => {
64
+ const style: Record<string, string | number> = {
65
+ width: addUnit(width.value),
66
+ height: addUnit(height.value),
67
+ }
68
+ return `${objToStyle(style)};${props.customStyle}`
69
+ })
70
+ let onScrollHandler = () => {}
71
+ const { proxy } = getCurrentInstance() as any
72
+
73
+ const resizeId = ref<string>(`resize${uuid()}`)
74
+
75
+ onMounted(() => {
76
+ // 初始化数据获取
77
+ const query = uni
78
+ .createSelectorQuery()
79
+ .in(proxy)
80
+ .select(`#${resizeId.value}`)
81
+ .boundingClientRect()
82
+ query.exec(([res]) => {
83
+ // 闭包记录容器高度
84
+ let lastHeight = res.height
85
+ let lastWidth = res.width
86
+ // 立即填充父容器高宽
87
+ height.value = lastHeight
88
+ width.value = lastWidth
89
+ // 监听滚动事件
90
+ onScrollHandler = () => {
91
+ const query = uni
92
+ .createSelectorQuery()
93
+ .in(proxy)
94
+ .select(`#${resizeId.value}`)
95
+ .boundingClientRect()
96
+ query.exec(([res]) => {
97
+ // 前两次滚动事件被触发,说明 created 的修改已渲染,通知用户代码当前容器大小
98
+ if (scrollEventCount.value++ === 0) {
99
+ const result: Record<string, string | number> = {}
100
+ ;['bottom', 'top', 'left', 'right', 'height', 'width'].forEach((propName) => {
101
+ result[propName] = res[propName]
102
+ })
103
+ emit('resize', result)
104
+ }
105
+ // 滚动条拉到底部会触发两次多余的事件,屏蔽掉。
106
+ if (scrollEventCount.value < 3) return
107
+ // 手动设置父容器高宽,防止父容器坍塌
108
+ // 滚动完,重新获取容器新的高度
109
+ const newHeight = res.height
110
+ const newWidth = res.width
111
+ // 立即填充父容器高宽
112
+ height.value = newHeight
113
+ width.value = newWidth
114
+ // 宽高都改变时,只需要触发一次 size 事件
115
+ const emitStack: number[] = []
116
+ if (newHeight !== lastHeight) {
117
+ lastHeight = newHeight
118
+ emitStack.push(1)
119
+ }
120
+ if (newWidth !== lastWidth) {
121
+ lastWidth = newWidth
122
+ emitStack.push(1)
123
+ }
124
+ if (emitStack.length !== 0) {
125
+ const result: Record<string, any> = {}
126
+ ;['bottom', 'top', 'left', 'right', 'height', 'width'].forEach((propName) => {
127
+ result[propName] = res[propName]
128
+ })
129
+ emit('resize', result)
130
+ }
131
+ // 滚动条拉到底部(如果使用 nextTick 效果更佳)
132
+ scrollToBottom({
133
+ lastWidth,
134
+ lastHeight,
135
+ })
136
+ })
137
+ }
138
+ // 滚动条拉到底部(如果使用 nextTick 效果更佳)
139
+ scrollToBottom({
140
+ lastWidth,
141
+ lastHeight,
142
+ })
143
+ })
144
+ })
145
+
146
+ function scrollToBottom({ lastWidth, lastHeight }: { lastWidth: number; lastHeight: number }) {
147
+ expandScrollTop.value = 100000 + lastHeight
148
+ shrinkScrollTop.value = 3 * height.value + lastHeight
149
+ expandScrollLeft.value = 100000 + lastWidth
150
+ shrinkScrollLeft.value = 3 * width.value + lastWidth
151
+ }
152
+ </script>
153
+ <style lang="scss" scoped>
154
+ @import './index.scss';
155
+ </style>
@@ -0,0 +1,10 @@
1
+ @import '../common/abstracts/variable';
2
+ @import '../common/abstracts/mixin';
3
+
4
+ @include b(row) {
5
+ &::after {
6
+ display: table;
7
+ clear: both;
8
+ content: '';
9
+ }
10
+ }
@@ -0,0 +1,16 @@
1
+ import { type InjectionKey } from 'vue'
2
+ import { baseProps, makeNumberProp } from '../common/props'
3
+
4
+ export type RowProvide = {
5
+ props: { gutter?: number }
6
+ }
7
+
8
+ export const ROW_KEY: InjectionKey<RowProvide> = Symbol('wd-row')
9
+
10
+ export const rowProps = {
11
+ ...baseProps,
12
+ /**
13
+ * 列元素之间的间距(单位为px)
14
+ */
15
+ gutter: makeNumberProp(0),
16
+ }
@@ -0,0 +1,63 @@
1
+ <template>
2
+ <view :class="`wd-row ${customClass}`" :style="style">
3
+ <!-- 每一行 -->
4
+ <slot />
5
+ </view>
6
+ </template>
7
+ <script lang="ts">
8
+ export default {
9
+ name: 'wd-row',
10
+ options: {
11
+ virtualHost: true,
12
+ addGlobalClass: true,
13
+ styleIsolation: 'shared',
14
+ },
15
+ }
16
+ </script>
17
+ <script lang="ts" setup>
18
+ import { ref, watch } from 'vue'
19
+ import { useChildren } from '../composables/useChildren'
20
+ import { ROW_KEY, rowProps } from './types'
21
+
22
+ const props = defineProps(rowProps)
23
+ const { linkChildren } = useChildren(ROW_KEY)
24
+
25
+ linkChildren({ props })
26
+
27
+ const style = ref<string>('')
28
+
29
+ watch(
30
+ () => props.gutter,
31
+ () => {
32
+ setGutter()
33
+ },
34
+ {
35
+ deep: true,
36
+ immediate: true,
37
+ },
38
+ )
39
+
40
+ function setGutter() {
41
+ const { gutter } = props
42
+ if (gutter < 0) {
43
+ console.error(
44
+ '[wot design] warning(wd-row): attribute gutter must be greater than or equal to 0',
45
+ )
46
+ }
47
+ const margin = `${gutter / 2}px`
48
+ const gutterStyle = gutter ? `margin-left: -${margin}; margin-right: -${margin};` : ''
49
+ style.value = `${gutterStyle}${props.customStyle}`
50
+ }
51
+ </script>
52
+ <style lang="scss" scoped>
53
+ @import '../common/abstracts/variable';
54
+ @import '../common/abstracts/mixin';
55
+
56
+ @include b(row) {
57
+ &::after {
58
+ display: table;
59
+ clear: both;
60
+ content: '';
61
+ }
62
+ }
63
+ </style>