wedux-ui 0.1.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 (231) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +184 -0
  3. package/miniprogram_dist/behaviors/formField.js +35 -0
  4. package/miniprogram_dist/components/avatar/avatar.js +70 -0
  5. package/miniprogram_dist/components/avatar/avatar.json +4 -0
  6. package/miniprogram_dist/components/avatar/avatar.scss +68 -0
  7. package/miniprogram_dist/components/avatar/avatar.wxml +15 -0
  8. package/miniprogram_dist/components/avatar-group/avatar-group.js +45 -0
  9. package/miniprogram_dist/components/avatar-group/avatar-group.json +7 -0
  10. package/miniprogram_dist/components/avatar-group/avatar-group.scss +4 -0
  11. package/miniprogram_dist/components/avatar-group/avatar-group.wxml +3 -0
  12. package/miniprogram_dist/components/back-top/back-top.js +68 -0
  13. package/miniprogram_dist/components/back-top/back-top.json +4 -0
  14. package/miniprogram_dist/components/back-top/back-top.scss +43 -0
  15. package/miniprogram_dist/components/back-top/back-top.wxml +10 -0
  16. package/miniprogram_dist/components/badge/badge.js +100 -0
  17. package/miniprogram_dist/components/badge/badge.json +4 -0
  18. package/miniprogram_dist/components/badge/badge.scss +98 -0
  19. package/miniprogram_dist/components/badge/badge.wxml +11 -0
  20. package/miniprogram_dist/components/button/button.js +152 -0
  21. package/miniprogram_dist/components/button/button.json +4 -0
  22. package/miniprogram_dist/components/button/button.scss +499 -0
  23. package/miniprogram_dist/components/button/button.wxml +21 -0
  24. package/miniprogram_dist/components/button-group/button-group.js +51 -0
  25. package/miniprogram_dist/components/button-group/button-group.json +4 -0
  26. package/miniprogram_dist/components/button-group/button-group.scss +8 -0
  27. package/miniprogram_dist/components/button-group/button-group.wxml +3 -0
  28. package/miniprogram_dist/components/calendar/calendar.js +308 -0
  29. package/miniprogram_dist/components/calendar/calendar.json +4 -0
  30. package/miniprogram_dist/components/calendar/calendar.scss +141 -0
  31. package/miniprogram_dist/components/calendar/calendar.wxml +47 -0
  32. package/miniprogram_dist/components/card/card.js +44 -0
  33. package/miniprogram_dist/components/card/card.json +4 -0
  34. package/miniprogram_dist/components/card/card.scss +143 -0
  35. package/miniprogram_dist/components/card/card.wxml +31 -0
  36. package/miniprogram_dist/components/checkbox/checkbox.js +43 -0
  37. package/miniprogram_dist/components/checkbox/checkbox.json +4 -0
  38. package/miniprogram_dist/components/checkbox/checkbox.scss +77 -0
  39. package/miniprogram_dist/components/checkbox/checkbox.wxml +13 -0
  40. package/miniprogram_dist/components/checkbox-button/checkbox-button.js +43 -0
  41. package/miniprogram_dist/components/checkbox-button/checkbox-button.json +4 -0
  42. package/miniprogram_dist/components/checkbox-button/checkbox-button.scss +39 -0
  43. package/miniprogram_dist/components/checkbox-button/checkbox-button.wxml +8 -0
  44. package/miniprogram_dist/components/checkbox-group/checkbox-group.js +84 -0
  45. package/miniprogram_dist/components/checkbox-group/checkbox-group.json +4 -0
  46. package/miniprogram_dist/components/checkbox-group/checkbox-group.scss +9 -0
  47. package/miniprogram_dist/components/checkbox-group/checkbox-group.wxml +3 -0
  48. package/miniprogram_dist/components/color-picker/color-picker.js +348 -0
  49. package/miniprogram_dist/components/color-picker/color-picker.json +7 -0
  50. package/miniprogram_dist/components/color-picker/color-picker.scss +383 -0
  51. package/miniprogram_dist/components/color-picker/color-picker.wxml +232 -0
  52. package/miniprogram_dist/components/date-picker/date-picker.js +1289 -0
  53. package/miniprogram_dist/components/date-picker/date-picker.json +7 -0
  54. package/miniprogram_dist/components/date-picker/date-picker.scss +468 -0
  55. package/miniprogram_dist/components/date-picker/date-picker.wxml +214 -0
  56. package/miniprogram_dist/components/divider/divider.js +34 -0
  57. package/miniprogram_dist/components/divider/divider.json +4 -0
  58. package/miniprogram_dist/components/divider/divider.scss +75 -0
  59. package/miniprogram_dist/components/divider/divider.wxml +8 -0
  60. package/miniprogram_dist/components/drawer/drawer.js +104 -0
  61. package/miniprogram_dist/components/drawer/drawer.json +4 -0
  62. package/miniprogram_dist/components/drawer/drawer.scss +171 -0
  63. package/miniprogram_dist/components/drawer/drawer.wxml +22 -0
  64. package/miniprogram_dist/components/ellipsis/ellipsis.js +38 -0
  65. package/miniprogram_dist/components/ellipsis/ellipsis.json +4 -0
  66. package/miniprogram_dist/components/ellipsis/ellipsis.scss +22 -0
  67. package/miniprogram_dist/components/ellipsis/ellipsis.wxml +7 -0
  68. package/miniprogram_dist/components/flex/flex.js +81 -0
  69. package/miniprogram_dist/components/flex/flex.json +4 -0
  70. package/miniprogram_dist/components/flex/flex.scss +4 -0
  71. package/miniprogram_dist/components/flex/flex.wxml +3 -0
  72. package/miniprogram_dist/components/float-button/float-button.js +78 -0
  73. package/miniprogram_dist/components/float-button/float-button.json +4 -0
  74. package/miniprogram_dist/components/float-button/float-button.scss +54 -0
  75. package/miniprogram_dist/components/float-button/float-button.wxml +9 -0
  76. package/miniprogram_dist/components/form/form.js +142 -0
  77. package/miniprogram_dist/components/form/form.json +4 -0
  78. package/miniprogram_dist/components/form/form.scss +11 -0
  79. package/miniprogram_dist/components/form/form.wxml +3 -0
  80. package/miniprogram_dist/components/form/validator.js +220 -0
  81. package/miniprogram_dist/components/form-item/form-item.js +240 -0
  82. package/miniprogram_dist/components/form-item/form-item.json +4 -0
  83. package/miniprogram_dist/components/form-item/form-item.scss +59 -0
  84. package/miniprogram_dist/components/form-item/form-item.wxml +33 -0
  85. package/miniprogram_dist/components/gradient-text/gradient-text.js +54 -0
  86. package/miniprogram_dist/components/gradient-text/gradient-text.json +4 -0
  87. package/miniprogram_dist/components/gradient-text/gradient-text.scss +7 -0
  88. package/miniprogram_dist/components/gradient-text/gradient-text.wxml +1 -0
  89. package/miniprogram_dist/components/h/h.js +60 -0
  90. package/miniprogram_dist/components/h/h.json +4 -0
  91. package/miniprogram_dist/components/h/h.scss +53 -0
  92. package/miniprogram_dist/components/h/h.wxml +1 -0
  93. package/miniprogram_dist/components/highlight/highlight.js +77 -0
  94. package/miniprogram_dist/components/highlight/highlight.json +4 -0
  95. package/miniprogram_dist/components/highlight/highlight.scss +8 -0
  96. package/miniprogram_dist/components/highlight/highlight.wxml +12 -0
  97. package/miniprogram_dist/components/infinite-scroll/infinite-scroll.js +31 -0
  98. package/miniprogram_dist/components/infinite-scroll/infinite-scroll.json +4 -0
  99. package/miniprogram_dist/components/infinite-scroll/infinite-scroll.scss +31 -0
  100. package/miniprogram_dist/components/infinite-scroll/infinite-scroll.wxml +12 -0
  101. package/miniprogram_dist/components/input/input.js +59 -0
  102. package/miniprogram_dist/components/input/input.json +4 -0
  103. package/miniprogram_dist/components/input/input.scss +96 -0
  104. package/miniprogram_dist/components/input/input.wxml +34 -0
  105. package/miniprogram_dist/components/input-otp/input-otp.js +106 -0
  106. package/miniprogram_dist/components/input-otp/input-otp.json +4 -0
  107. package/miniprogram_dist/components/input-otp/input-otp.scss +122 -0
  108. package/miniprogram_dist/components/input-otp/input-otp.wxml +38 -0
  109. package/miniprogram_dist/components/layout/layout.js +50 -0
  110. package/miniprogram_dist/components/layout/layout.json +4 -0
  111. package/miniprogram_dist/components/layout/layout.scss +10 -0
  112. package/miniprogram_dist/components/layout/layout.wxml +3 -0
  113. package/miniprogram_dist/components/layout-content/layout-content.js +47 -0
  114. package/miniprogram_dist/components/layout-content/layout-content.json +4 -0
  115. package/miniprogram_dist/components/layout-content/layout-content.scss +5 -0
  116. package/miniprogram_dist/components/layout-content/layout-content.wxml +13 -0
  117. package/miniprogram_dist/components/layout-footer/layout-footer.js +59 -0
  118. package/miniprogram_dist/components/layout-footer/layout-footer.json +4 -0
  119. package/miniprogram_dist/components/layout-footer/layout-footer.scss +23 -0
  120. package/miniprogram_dist/components/layout-footer/layout-footer.wxml +16 -0
  121. package/miniprogram_dist/components/layout-header/layout-header.js +59 -0
  122. package/miniprogram_dist/components/layout-header/layout-header.json +4 -0
  123. package/miniprogram_dist/components/layout-header/layout-header.scss +23 -0
  124. package/miniprogram_dist/components/layout-header/layout-header.wxml +16 -0
  125. package/miniprogram_dist/components/layout-sider/layout-sider.js +48 -0
  126. package/miniprogram_dist/components/layout-sider/layout-sider.json +4 -0
  127. package/miniprogram_dist/components/layout-sider/layout-sider.scss +13 -0
  128. package/miniprogram_dist/components/layout-sider/layout-sider.wxml +5 -0
  129. package/miniprogram_dist/components/list/list.js +55 -0
  130. package/miniprogram_dist/components/list/list.json +4 -0
  131. package/miniprogram_dist/components/list/list.scss +51 -0
  132. package/miniprogram_dist/components/list/list.wxml +9 -0
  133. package/miniprogram_dist/components/list-item/list-item.js +24 -0
  134. package/miniprogram_dist/components/list-item/list-item.json +4 -0
  135. package/miniprogram_dist/components/list-item/list-item.scss +51 -0
  136. package/miniprogram_dist/components/list-item/list-item.wxml +14 -0
  137. package/miniprogram_dist/components/navigation-bar/navigation-bar.js +77 -0
  138. package/miniprogram_dist/components/navigation-bar/navigation-bar.json +4 -0
  139. package/miniprogram_dist/components/navigation-bar/navigation-bar.scss +63 -0
  140. package/miniprogram_dist/components/navigation-bar/navigation-bar.wxml +35 -0
  141. package/miniprogram_dist/components/number-animation/number-animation.js +124 -0
  142. package/miniprogram_dist/components/number-animation/number-animation.json +4 -0
  143. package/miniprogram_dist/components/number-animation/number-animation.scss +3 -0
  144. package/miniprogram_dist/components/number-animation/number-animation.wxml +1 -0
  145. package/miniprogram_dist/components/popover/popover.js +183 -0
  146. package/miniprogram_dist/components/popover/popover.json +4 -0
  147. package/miniprogram_dist/components/popover/popover.scss +69 -0
  148. package/miniprogram_dist/components/popover/popover.wxml +19 -0
  149. package/miniprogram_dist/components/qr-code/qr-code.js +216 -0
  150. package/miniprogram_dist/components/qr-code/qr-code.json +4 -0
  151. package/miniprogram_dist/components/qr-code/qr-code.scss +8 -0
  152. package/miniprogram_dist/components/qr-code/qr-code.wxml +16 -0
  153. package/miniprogram_dist/components/radio/radio.js +38 -0
  154. package/miniprogram_dist/components/radio/radio.json +4 -0
  155. package/miniprogram_dist/components/radio/radio.scss +50 -0
  156. package/miniprogram_dist/components/radio/radio.wxml +12 -0
  157. package/miniprogram_dist/components/radio-button/radio-button.js +39 -0
  158. package/miniprogram_dist/components/radio-button/radio-button.json +4 -0
  159. package/miniprogram_dist/components/radio-button/radio-button.scss +39 -0
  160. package/miniprogram_dist/components/radio-button/radio-button.wxml +8 -0
  161. package/miniprogram_dist/components/radio-group/radio-group.js +72 -0
  162. package/miniprogram_dist/components/radio-group/radio-group.json +4 -0
  163. package/miniprogram_dist/components/radio-group/radio-group.scss +9 -0
  164. package/miniprogram_dist/components/radio-group/radio-group.wxml +3 -0
  165. package/miniprogram_dist/components/rate/rate.js +90 -0
  166. package/miniprogram_dist/components/rate/rate.json +4 -0
  167. package/miniprogram_dist/components/rate/rate.scss +59 -0
  168. package/miniprogram_dist/components/rate/rate.wxml +16 -0
  169. package/miniprogram_dist/components/select/select.js +201 -0
  170. package/miniprogram_dist/components/select/select.json +7 -0
  171. package/miniprogram_dist/components/select/select.scss +235 -0
  172. package/miniprogram_dist/components/select/select.wxml +79 -0
  173. package/miniprogram_dist/components/stepper/stepper.js +113 -0
  174. package/miniprogram_dist/components/stepper/stepper.json +4 -0
  175. package/miniprogram_dist/components/stepper/stepper.scss +73 -0
  176. package/miniprogram_dist/components/stepper/stepper.wxml +23 -0
  177. package/miniprogram_dist/components/switch/switch.js +42 -0
  178. package/miniprogram_dist/components/switch/switch.json +4 -0
  179. package/miniprogram_dist/components/switch/switch.scss +77 -0
  180. package/miniprogram_dist/components/switch/switch.wxml +10 -0
  181. package/miniprogram_dist/components/tab-bar/tab-bar.js +53 -0
  182. package/miniprogram_dist/components/tab-bar/tab-bar.json +4 -0
  183. package/miniprogram_dist/components/tab-bar/tab-bar.scss +53 -0
  184. package/miniprogram_dist/components/tab-bar/tab-bar.wxml +12 -0
  185. package/miniprogram_dist/components/tag/tag.js +87 -0
  186. package/miniprogram_dist/components/tag/tag.json +4 -0
  187. package/miniprogram_dist/components/tag/tag.scss +138 -0
  188. package/miniprogram_dist/components/tag/tag.wxml +12 -0
  189. package/miniprogram_dist/components/textarea/textarea.js +46 -0
  190. package/miniprogram_dist/components/textarea/textarea.json +4 -0
  191. package/miniprogram_dist/components/textarea/textarea.scss +51 -0
  192. package/miniprogram_dist/components/textarea/textarea.wxml +20 -0
  193. package/miniprogram_dist/components/theme-provider/presets.js +101 -0
  194. package/miniprogram_dist/components/theme-provider/theme-provider.js +34 -0
  195. package/miniprogram_dist/components/theme-provider/theme-provider.json +4 -0
  196. package/miniprogram_dist/components/theme-provider/theme-provider.scss +3 -0
  197. package/miniprogram_dist/components/theme-provider/theme-provider.wxml +3 -0
  198. package/miniprogram_dist/components/time-picker/time-picker.js +136 -0
  199. package/miniprogram_dist/components/time-picker/time-picker.json +7 -0
  200. package/miniprogram_dist/components/time-picker/time-picker.scss +135 -0
  201. package/miniprogram_dist/components/time-picker/time-picker.wxml +47 -0
  202. package/miniprogram_dist/components/tooltip/tooltip.js +179 -0
  203. package/miniprogram_dist/components/tooltip/tooltip.json +4 -0
  204. package/miniprogram_dist/components/tooltip/tooltip.scss +66 -0
  205. package/miniprogram_dist/components/tooltip/tooltip.wxml +17 -0
  206. package/miniprogram_dist/components/tree/tree.js +647 -0
  207. package/miniprogram_dist/components/tree/tree.json +4 -0
  208. package/miniprogram_dist/components/tree/tree.scss +178 -0
  209. package/miniprogram_dist/components/tree/tree.wxml +59 -0
  210. package/miniprogram_dist/components/tree-select/tree-select.js +260 -0
  211. package/miniprogram_dist/components/tree-select/tree-select.json +8 -0
  212. package/miniprogram_dist/components/tree-select/tree-select.scss +250 -0
  213. package/miniprogram_dist/components/tree-select/tree-select.wxml +118 -0
  214. package/miniprogram_dist/components/upload/upload.js +387 -0
  215. package/miniprogram_dist/components/upload/upload.json +4 -0
  216. package/miniprogram_dist/components/upload/upload.scss +258 -0
  217. package/miniprogram_dist/components/upload/upload.wxml +142 -0
  218. package/miniprogram_dist/components/watermark/watermark.js +260 -0
  219. package/miniprogram_dist/components/watermark/watermark.json +4 -0
  220. package/miniprogram_dist/components/watermark/watermark.scss +35 -0
  221. package/miniprogram_dist/components/watermark/watermark.wxml +13 -0
  222. package/miniprogram_dist/libs/qrcodegen.js +714 -0
  223. package/miniprogram_dist/libs/seemly.min.js +547 -0
  224. package/miniprogram_dist/libs/tempo_1_0_0.js +1264 -0
  225. package/miniprogram_dist/libs/validator_13_56_26.min.js +5282 -0
  226. package/miniprogram_dist/styles/demo.scss +96 -0
  227. package/miniprogram_dist/styles/iconfont.scss +91 -0
  228. package/miniprogram_dist/styles/theme.scss +126 -0
  229. package/miniprogram_dist/styles/tokens.scss +292 -0
  230. package/miniprogram_dist/utils/relations.js +21 -0
  231. package/package.json +25 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bitter Bar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,184 @@
1
+ <p align="center">
2
+ <img src="https://img.shields.io/npm/v/wedux-ui?color=a1b858&label=npm" alt="npm version" />
3
+ <img src="https://img.shields.io/npm/l/wedux-ui?color=50a36f" alt="license" />
4
+ <img src="https://img.shields.io/badge/platform-wechat--miniprogram-07c160" alt="platform" />
5
+ </p>
6
+
7
+ <h1 align="center">wedux-ui</h1>
8
+
9
+ <p align="center">轻量、可定制的微信小程序原生组件库</p>
10
+
11
+ <p align="center">
12
+ 零依赖 · CSS 变量主题 · 深色模式 · 50+ 组件
13
+ </p>
14
+
15
+ ---
16
+
17
+ ## 特性
18
+
19
+ - **零依赖** — 纯原生小程序,无 npm 运行时依赖
20
+ - **主题定制** — 基于 CSS 变量的 Design Token 体系,支持组件级覆盖
21
+ - **深色模式** — 内置 light / dark 预设,跟随系统或手动切换
22
+ - **按需引用** — 只注册用到的组件,不增加包体积
23
+ - **表单驱动** — 完整的 Form / FormItem 校验体系,统一表单组件行为
24
+
25
+ ## 安装
26
+
27
+ ```bash
28
+ npm install wedux-ui
29
+ ```
30
+
31
+ 安装后在**微信开发者工具**中点击 **工具 → 构建 npm**,等待构建完成即可使用。
32
+
33
+ ## 快速上手
34
+
35
+ 在页面或组件的 `.json` 中注册:
36
+
37
+ ```json
38
+ {
39
+ "usingComponents": {
40
+ "w-button": "wedux-ui/components/button/button",
41
+ "w-input": "wedux-ui/components/input/input"
42
+ }
43
+ }
44
+ ```
45
+
46
+ 在 `.wxml` 中使用:
47
+
48
+ ```html
49
+ <w-button type="primary" bind:tap="onTap">提交</w-button>
50
+ <w-input placeholder="请输入" bind:change="onChange" />
51
+ ```
52
+
53
+ ## 组件一览
54
+
55
+ ### 通用
56
+
57
+ | 组件 | 说明 |
58
+ | ----------- | ---------------- |
59
+ | Button | 按钮 |
60
+ | ButtonGroup | 按钮组 |
61
+ | FloatButton | 浮动按钮 |
62
+ | Icon | 图标(iconfont) |
63
+
64
+ ### 布局
65
+
66
+ | 组件 | 说明 |
67
+ | ------- | --------------------------------------------- |
68
+ | Flex | 弹性布局 |
69
+ | Layout | 页面布局(Header / Content / Footer / Sider) |
70
+ | Divider | 分割线 |
71
+
72
+ ### 数据展示
73
+
74
+ | 组件 | 说明 |
75
+ | -------------------- | ------------- |
76
+ | Avatar / AvatarGroup | 头像 / 头像组 |
77
+ | Badge | 徽标 |
78
+ | Card | 卡片 |
79
+ | Ellipsis | 文本省略 |
80
+ | GradientText | 渐变文字 |
81
+ | H | 标题 |
82
+ | Highlight | 文本高亮 |
83
+ | List / ListItem | 列表 |
84
+ | NumberAnimation | 数字动画 |
85
+ | QrCode | 二维码 |
86
+ | Tag | 标签 |
87
+ | Watermark | 水印 |
88
+ | Tree | 树形控件 |
89
+
90
+ ### 数据录入
91
+
92
+ | 组件 | 说明 |
93
+ | ------------------------ | ------------- |
94
+ | Form / FormItem | 表单 / 表单项 |
95
+ | Input | 输入框 |
96
+ | Textarea | 多行输入 |
97
+ | InputOtp | 验证码输入 |
98
+ | Select | 选择器 |
99
+ | Switch | 开关 |
100
+ | Radio / RadioGroup | 单选 |
101
+ | Checkbox / CheckboxGroup | 多选 |
102
+ | Rate | 评分 |
103
+ | Stepper | 步进器 |
104
+ | DatePicker | 日期选择 |
105
+ | TimePicker | 时间选择 |
106
+ | Calendar | 日历 |
107
+ | ColorPicker | 颜色选择 |
108
+ | TreeSelect | 树选择 |
109
+ | Upload | 上传 |
110
+
111
+ ### 导航
112
+
113
+ | 组件 | 说明 |
114
+ | ------------- | ------------ |
115
+ | NavigationBar | 自定义导航栏 |
116
+ | TabBar | 标签栏 |
117
+ | BackTop | 回到顶部 |
118
+
119
+ ### 反馈
120
+
121
+ | 组件 | 说明 |
122
+ | -------------- | -------- |
123
+ | Drawer | 抽屉 |
124
+ | Popover | 弹出气泡 |
125
+ | Tooltip | 文字提示 |
126
+ | InfiniteScroll | 无限滚动 |
127
+
128
+ ### 主题
129
+
130
+ | 组件 | 说明 |
131
+ | ------------- | -------------- |
132
+ | ThemeProvider | 主题配置提供者 |
133
+
134
+ ## 主题定制
135
+
136
+ 通过 `ThemeProvider` 组件覆盖设计变量:
137
+
138
+ ```html
139
+ <w-theme-provider theme="{{theme}}">
140
+ <w-button type="primary">自定义主题</w-button>
141
+ </w-theme-provider>
142
+ ```
143
+
144
+ ```js
145
+ const { lightTheme } = require('wedux-ui/components/theme-provider/presets');
146
+
147
+ Page({
148
+ data: {
149
+ theme: {
150
+ ...lightTheme,
151
+ '--w-primary-color': '#8b5cf6',
152
+ },
153
+ },
154
+ });
155
+ ```
156
+
157
+ 也可以通过组件级 CSS 变量精确控制单个组件:
158
+
159
+ ```css
160
+ page {
161
+ --w-btn-height: 44px;
162
+ --w-btn-radius: 12px;
163
+ --w-input-radius: 8px;
164
+ }
165
+ ```
166
+
167
+ ## 开发
168
+
169
+ ```bash
170
+ # 安装依赖
171
+ pnpm install
172
+
173
+ # 格式化代码
174
+ pnpm format
175
+
176
+ # 构建 npm 产物
177
+ pnpm build
178
+ ```
179
+
180
+ 使用**微信开发者工具**打开项目根目录即可预览 Demo。
181
+
182
+ ## 协议
183
+
184
+ [MIT](./LICENSE)
@@ -0,0 +1,35 @@
1
+ // src/behaviors/formField.js
2
+ module.exports = Behavior({
3
+ data: {
4
+ _formItemSize: '',
5
+ _formItemDisabled: false,
6
+ },
7
+
8
+ methods: {
9
+ _setFormItemContext(ctx) {
10
+ this.setData({
11
+ _formItemSize: ctx.size || '',
12
+ _formItemDisabled: ctx.disabled || false,
13
+ });
14
+ },
15
+
16
+ _getFormItem() {
17
+ const nodes = this.getRelationNodes('../form-item/form-item');
18
+ return nodes && nodes.length > 0 ? nodes[0] : null;
19
+ },
20
+
21
+ _notifyChange() {
22
+ const formItem = this._getFormItem();
23
+ if (formItem) formItem._handleFieldChange();
24
+ },
25
+
26
+ _notifyBlur() {
27
+ const formItem = this._getFormItem();
28
+ if (formItem) formItem._handleFieldBlur();
29
+ },
30
+
31
+ _isDisabled() {
32
+ return this.data.disabled || this.data._formItemDisabled;
33
+ },
34
+ },
35
+ });
@@ -0,0 +1,70 @@
1
+ Component({
2
+ relations: {
3
+ '../avatar-group/avatar-group': {
4
+ type: 'ancestor',
5
+ unlinked() {
6
+ this.setData({ _groupSize: '', _groupRound: false, _groupOverlap: false });
7
+ },
8
+ },
9
+ },
10
+
11
+ properties: {
12
+ size: {
13
+ type: String,
14
+ value: 'medium', // small | medium | large
15
+ },
16
+ src: {
17
+ type: String,
18
+ value: '',
19
+ },
20
+ round: {
21
+ type: Boolean,
22
+ value: false,
23
+ },
24
+ bordered: {
25
+ type: Boolean,
26
+ value: false,
27
+ },
28
+ color: {
29
+ type: String,
30
+ value: '',
31
+ },
32
+ fallbackSrc: {
33
+ type: String,
34
+ value: '',
35
+ },
36
+ },
37
+
38
+ data: {
39
+ _currentSrc: '',
40
+ _imgError: false,
41
+ _groupSize: '',
42
+ _groupRound: false,
43
+ _groupOverlap: false,
44
+ },
45
+
46
+ observers: {
47
+ src(src) {
48
+ this.setData({ _currentSrc: src, _imgError: false });
49
+ },
50
+ },
51
+
52
+ methods: {
53
+ handleImgError() {
54
+ const fallbackSrc = this.data.fallbackSrc;
55
+ if (fallbackSrc && this.data._currentSrc !== fallbackSrc) {
56
+ this.setData({ _currentSrc: fallbackSrc });
57
+ } else {
58
+ this.setData({ _imgError: true });
59
+ }
60
+ },
61
+
62
+ _setGroupContext(ctx) {
63
+ this.setData({
64
+ _groupSize: ctx.size || '',
65
+ _groupRound: !!ctx.round,
66
+ _groupOverlap: !!ctx.overlap,
67
+ });
68
+ },
69
+ },
70
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared"
4
+ }
@@ -0,0 +1,68 @@
1
+ .w-avatar {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ justify-content: center;
5
+ width: var(--size-avatar-md);
6
+ height: var(--size-avatar-md);
7
+ border-radius: var(--w-avatar-radius);
8
+ background-color: var(--w-avatar-bg);
9
+ overflow: hidden;
10
+ flex-shrink: 0;
11
+ position: relative;
12
+ box-sizing: border-box;
13
+ font-size: var(--font-size-md);
14
+ font-weight: 500;
15
+ color: var(--color-text-primary);
16
+ }
17
+
18
+ /* Sizes */
19
+ .w-avatar--small {
20
+ width: var(--size-avatar-sm);
21
+ height: var(--size-avatar-sm);
22
+ font-size: var(--font-size-sm);
23
+ }
24
+
25
+ .w-avatar--medium {
26
+ width: var(--size-avatar-md);
27
+ height: var(--size-avatar-md);
28
+ font-size: var(--font-size-md);
29
+ }
30
+
31
+ .w-avatar--large {
32
+ width: var(--size-avatar-lg);
33
+ height: var(--size-avatar-lg);
34
+ font-size: var(--font-size-lg);
35
+ }
36
+
37
+ /* Round */
38
+ .w-avatar--round {
39
+ border-radius: 50%;
40
+ }
41
+
42
+ /* Bordered — white ring, useful when overlapping */
43
+ .w-avatar--bordered {
44
+ border: 4rpx solid var(--color-bg-elevated);
45
+ }
46
+
47
+ /* Group overlap */
48
+ .w-avatar--group-overlap {
49
+ margin-left: -20rpx;
50
+ }
51
+
52
+ /* Image */
53
+ .w-avatar__img {
54
+ width: 100%;
55
+ height: 100%;
56
+ display: block;
57
+ }
58
+
59
+ /* Text / icon content */
60
+ .w-avatar__content {
61
+ display: flex;
62
+ align-items: center;
63
+ justify-content: center;
64
+ width: 100%;
65
+ height: 100%;
66
+ line-height: 1;
67
+ white-space: nowrap;
68
+ }
@@ -0,0 +1,15 @@
1
+ <view
2
+ class="w-avatar w-avatar--{{_groupSize || size}} {{(round || _groupRound) ? 'w-avatar--round' : ''}} {{bordered ? 'w-avatar--bordered' : ''}} {{_groupOverlap ? 'w-avatar--group-overlap' : ''}}"
3
+ style="{{color ? 'background-color: ' + color + ';' : ''}}"
4
+ >
5
+ <image
6
+ wx:if="{{_currentSrc && !_imgError}}"
7
+ class="w-avatar__img"
8
+ src="{{_currentSrc}}"
9
+ mode="aspectFill"
10
+ binderror="handleImgError"
11
+ ></image>
12
+ <view wx:else class="w-avatar__content">
13
+ <slot></slot>
14
+ </view>
15
+ </view>
@@ -0,0 +1,45 @@
1
+ Component({
2
+ relations: {
3
+ '../avatar/avatar': {
4
+ type: 'descendant',
5
+ linked() {
6
+ this._syncChildren();
7
+ },
8
+ unlinked() {
9
+ this._syncChildren();
10
+ },
11
+ },
12
+ },
13
+
14
+ properties: {
15
+ size: {
16
+ type: String,
17
+ value: '', // 统一覆盖子头像尺寸,空则各自保留
18
+ },
19
+ round: {
20
+ type: Boolean,
21
+ value: false,
22
+ },
23
+ },
24
+
25
+ observers: {
26
+ 'size, round'() {
27
+ this._syncChildren();
28
+ },
29
+ },
30
+
31
+ methods: {
32
+ _syncChildren() {
33
+ const children = this.getRelationNodes('../avatar/avatar');
34
+ const size = this.data.size;
35
+ const round = this.data.round;
36
+ children.forEach((child, index) => {
37
+ child._setGroupContext({
38
+ size,
39
+ round,
40
+ overlap: index > 0,
41
+ });
42
+ });
43
+ },
44
+ },
45
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared",
4
+ "usingComponents": {
5
+ "w-avatar": "/src/components/avatar/avatar"
6
+ }
7
+ }
@@ -0,0 +1,4 @@
1
+ .w-avatar-group {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ }
@@ -0,0 +1,3 @@
1
+ <view class="w-avatar-group">
2
+ <slot></slot>
3
+ </view>
@@ -0,0 +1,68 @@
1
+ Component({
2
+ properties: {
3
+ scrollTop: {
4
+ type: Number,
5
+ value: 0,
6
+ },
7
+ visibilityHeight: {
8
+ type: Number,
9
+ value: 180,
10
+ },
11
+ right: {
12
+ type: Number,
13
+ value: 48,
14
+ },
15
+ bottom: {
16
+ type: Number,
17
+ value: 96,
18
+ },
19
+ duration: {
20
+ type: Number,
21
+ value: 300,
22
+ },
23
+ },
24
+
25
+ data: {
26
+ _visible: false,
27
+ _style: '',
28
+ },
29
+
30
+ lifetimes: {
31
+ ready() {
32
+ this._computeStyle();
33
+ },
34
+ },
35
+
36
+ observers: {
37
+ 'right, bottom'() {
38
+ this._computeStyle();
39
+ },
40
+ scrollTop(val) {
41
+ const visible = val >= this.data.visibilityHeight;
42
+ if (visible !== this.data._visible) {
43
+ this.setData({ _visible: visible });
44
+ }
45
+ },
46
+ },
47
+
48
+ methods: {
49
+ _computeStyle() {
50
+ const { right, bottom } = this.data;
51
+ const parts = [
52
+ 'position: fixed',
53
+ 'z-index: 999',
54
+ `right: ${right}rpx`,
55
+ `bottom: ${bottom}rpx`,
56
+ ];
57
+ this.setData({ _style: parts.join('; ') });
58
+ },
59
+
60
+ handleTap() {
61
+ wx.pageScrollTo({
62
+ scrollTop: 0,
63
+ duration: this.data.duration,
64
+ });
65
+ this.triggerEvent('click');
66
+ },
67
+ },
68
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared"
4
+ }
@@ -0,0 +1,43 @@
1
+ @import '../../styles/iconfont.scss';
2
+
3
+ .w-back-top {
4
+ display: flex;
5
+ align-items: center;
6
+ justify-content: center;
7
+ width: 80rpx;
8
+ height: 80rpx;
9
+ border-radius: 50%;
10
+ background: var(--color-bg-elevated);
11
+ box-shadow: var(--shadow-float);
12
+ position: relative;
13
+ overflow: hidden;
14
+ animation: w-back-top-fade-in 0.2s ease-out;
15
+ }
16
+
17
+ .w-back-top__icon {
18
+ font-size: 36rpx;
19
+ color: var(--color-text-primary);
20
+ }
21
+
22
+ /* Press overlay */
23
+ .w-back-top--active::after {
24
+ content: '';
25
+ position: absolute;
26
+ top: 0;
27
+ left: 0;
28
+ right: 0;
29
+ bottom: 0;
30
+ background: var(--color-press-overlay-light);
31
+ border-radius: inherit;
32
+ }
33
+
34
+ @keyframes w-back-top-fade-in {
35
+ from {
36
+ opacity: 0;
37
+ transform: scale(0.8);
38
+ }
39
+ to {
40
+ opacity: 1;
41
+ transform: scale(1);
42
+ }
43
+ }
@@ -0,0 +1,10 @@
1
+ <view
2
+ wx:if="{{_visible}}"
3
+ class="w-back-top"
4
+ style="{{_style}}"
5
+ hover-class="w-back-top--active"
6
+ hover-stay-time="70"
7
+ bindtap="handleTap"
8
+ >
9
+ <text class="iconfont icon-top w-back-top__icon"></text>
10
+ </view>
@@ -0,0 +1,100 @@
1
+ Component({
2
+ properties: {
3
+ value: {
4
+ type: null,
5
+ value: '',
6
+ },
7
+ max: {
8
+ type: Number,
9
+ value: 0,
10
+ },
11
+ dot: {
12
+ type: Boolean,
13
+ value: false,
14
+ },
15
+ type: {
16
+ type: String,
17
+ value: 'default',
18
+ },
19
+ show: {
20
+ type: Boolean,
21
+ value: true,
22
+ },
23
+ showZero: {
24
+ type: Boolean,
25
+ value: false,
26
+ },
27
+ processing: {
28
+ type: Boolean,
29
+ value: false,
30
+ },
31
+ color: {
32
+ type: String,
33
+ value: '',
34
+ },
35
+ offsetX: {
36
+ type: Number,
37
+ value: 0,
38
+ },
39
+ offsetY: {
40
+ type: Number,
41
+ value: 0,
42
+ },
43
+ },
44
+
45
+ data: {
46
+ _visible: false,
47
+ _displayValue: '',
48
+ _style: '',
49
+ },
50
+
51
+ observers: {
52
+ 'value, max, dot, show, showZero, color, offsetX, offsetY': function (
53
+ value,
54
+ max,
55
+ dot,
56
+ show,
57
+ showZero,
58
+ color,
59
+ offsetX,
60
+ offsetY,
61
+ ) {
62
+ // Visibility
63
+ let visible = show;
64
+ if (visible && !dot) {
65
+ if (value === '' || value === null || value === undefined) {
66
+ visible = false;
67
+ } else if (!showZero && Number(value) === 0) {
68
+ visible = false;
69
+ }
70
+ }
71
+
72
+ // Display value
73
+ let displayValue = '';
74
+ if (!dot && visible) {
75
+ const numVal = Number(value);
76
+ if (max > 0 && !isNaN(numVal) && numVal > max) {
77
+ displayValue = `${max}+`;
78
+ } else {
79
+ displayValue = String(value);
80
+ }
81
+ }
82
+
83
+ // Style (custom color + offset)
84
+ const parts = [];
85
+ if (color) {
86
+ parts.push(`--_bg: ${color}`);
87
+ parts.push(`background-color: ${color}`);
88
+ }
89
+ if (offsetX || offsetY) {
90
+ parts.push(`transform: translate(calc(50% + ${offsetX}rpx), calc(-50% + ${offsetY}rpx))`);
91
+ }
92
+
93
+ this.setData({
94
+ _visible: visible,
95
+ _displayValue: displayValue,
96
+ _style: parts.join('; '),
97
+ });
98
+ },
99
+ },
100
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared"
4
+ }