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
@@ -0,0 +1,183 @@
1
+ Component({
2
+ options: {
3
+ multipleSlots: true,
4
+ },
5
+
6
+ properties: {
7
+ show: {
8
+ type: Boolean,
9
+ value: false,
10
+ },
11
+ trigger: {
12
+ type: String,
13
+ value: 'tap',
14
+ },
15
+ placement: {
16
+ type: String,
17
+ value: 'top',
18
+ },
19
+ showArrow: {
20
+ type: Boolean,
21
+ value: true,
22
+ },
23
+ disabled: {
24
+ type: Boolean,
25
+ value: false,
26
+ },
27
+ },
28
+
29
+ data: {
30
+ _visible: false,
31
+ _active: false,
32
+ _bodyStyle: '',
33
+ _arrowStyle: '',
34
+ _arrowClass: '',
35
+ },
36
+
37
+ observers: {
38
+ show(val) {
39
+ if (val && !this.data._visible) {
40
+ this._open();
41
+ } else if (!val && this.data._visible) {
42
+ this._close();
43
+ }
44
+ },
45
+ },
46
+
47
+ lifetimes: {
48
+ detached() {
49
+ if (this._closeTimer) {
50
+ clearTimeout(this._closeTimer);
51
+ this._closeTimer = null;
52
+ }
53
+ },
54
+ },
55
+
56
+ methods: {
57
+ _open() {
58
+ if (this._closeTimer) {
59
+ clearTimeout(this._closeTimer);
60
+ this._closeTimer = null;
61
+ }
62
+ // Render body first (opacity 0) so we can measure its size
63
+ this.setData({ _visible: true }, () => {
64
+ this._updatePosition(() => {
65
+ setTimeout(() => this.setData({ _active: true }), 30);
66
+ });
67
+ });
68
+ },
69
+
70
+ _close() {
71
+ this.setData({ _active: false });
72
+ this._closeTimer = setTimeout(() => {
73
+ this.setData({ _visible: false });
74
+ this._closeTimer = null;
75
+ }, 200);
76
+ },
77
+
78
+ _updatePosition(cb) {
79
+ const query = this.createSelectorQuery();
80
+ query.select('.w-popover__trigger').boundingClientRect();
81
+ query.select('.w-popover__body').boundingClientRect();
82
+ query.exec(([triggerRect, bodyRect]) => {
83
+ if (!triggerRect || !bodyRect) {
84
+ cb && cb();
85
+ return;
86
+ }
87
+
88
+ const { windowWidth, windowHeight } = wx.getWindowInfo();
89
+ const tW = triggerRect.width;
90
+ const tH = triggerRect.height;
91
+ const bW = bodyRect.width;
92
+ const bH = bodyRect.height;
93
+ const gap = 8;
94
+ const safeMargin = 4; // minimum distance from viewport edge
95
+
96
+ let [main, align] = this.data.placement.split('-');
97
+
98
+ // Flip main axis if it would overflow but the opposite side has room
99
+ if (
100
+ main === 'top' &&
101
+ triggerRect.top - bH - gap < safeMargin &&
102
+ triggerRect.bottom + bH + gap + safeMargin <= windowHeight
103
+ ) {
104
+ main = 'bottom';
105
+ } else if (
106
+ main === 'bottom' &&
107
+ triggerRect.bottom + bH + gap + safeMargin > windowHeight &&
108
+ triggerRect.top - bH - gap >= safeMargin
109
+ ) {
110
+ main = 'top';
111
+ } else if (
112
+ main === 'left' &&
113
+ triggerRect.left - bW - gap < safeMargin &&
114
+ triggerRect.right + bW + gap + safeMargin <= windowWidth
115
+ ) {
116
+ main = 'right';
117
+ } else if (
118
+ main === 'right' &&
119
+ triggerRect.right + bW + gap + safeMargin > windowWidth &&
120
+ triggerRect.left - bW - gap >= safeMargin
121
+ ) {
122
+ main = 'left';
123
+ }
124
+
125
+ let bodyStyle = '';
126
+ let arrowStyle = '';
127
+ const arrowClass = `w-popover__arrow--${main}`;
128
+
129
+ if (main === 'top' || main === 'bottom') {
130
+ bodyStyle += main === 'top' ? `bottom: ${tH + gap}px;` : `top: ${tH + gap}px;`;
131
+
132
+ // Calculate horizontal offset relative to trigger left edge
133
+ let bodyLeft = align === 'start' ? 0 : align === 'end' ? tW - bW : (tW - bW) / 2;
134
+
135
+ // Shift to keep body within viewport
136
+ const absLeft = triggerRect.left + bodyLeft;
137
+ const absRight = absLeft + bW;
138
+ if (absLeft < safeMargin) {
139
+ bodyLeft += safeMargin - absLeft;
140
+ } else if (absRight > windowWidth - safeMargin) {
141
+ bodyLeft -= absRight - (windowWidth - safeMargin);
142
+ }
143
+
144
+ bodyStyle += `left: ${bodyLeft}px;`;
145
+ // Arrow points to trigger center
146
+ arrowStyle = `left: ${tW / 2 - bodyLeft}px;`;
147
+ } else {
148
+ bodyStyle += main === 'left' ? `right: ${tW + gap}px;` : `left: ${tW + gap}px;`;
149
+
150
+ // Calculate vertical offset relative to trigger top edge
151
+ let bodyTop = align === 'start' ? 0 : align === 'end' ? tH - bH : (tH - bH) / 2;
152
+
153
+ // Shift to keep body within viewport
154
+ const absTop = triggerRect.top + bodyTop;
155
+ const absBottom = absTop + bH;
156
+ if (absTop < safeMargin) {
157
+ bodyTop += safeMargin - absTop;
158
+ } else if (absBottom > windowHeight - safeMargin) {
159
+ bodyTop -= absBottom - (windowHeight - safeMargin);
160
+ }
161
+
162
+ bodyStyle += `top: ${bodyTop}px;`;
163
+ // Arrow points to trigger center
164
+ arrowStyle = `top: ${tH / 2 - bodyTop}px;`;
165
+ }
166
+
167
+ this.setData({ _bodyStyle: bodyStyle, _arrowStyle: arrowStyle, _arrowClass: arrowClass });
168
+ cb && cb();
169
+ });
170
+ },
171
+
172
+ handleTriggerTap() {
173
+ if (this.data.disabled || this.data.trigger !== 'tap') return;
174
+ const willShow = !this.data._visible;
175
+ if (willShow) {
176
+ this._open();
177
+ } else {
178
+ this._close();
179
+ }
180
+ this.triggerEvent('update:show', { show: willShow });
181
+ },
182
+ },
183
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared"
4
+ }
@@ -0,0 +1,69 @@
1
+ $arrow-size: 16rpx;
2
+
3
+ .w-popover {
4
+ position: relative;
5
+ display: inline-block;
6
+ }
7
+
8
+ .w-popover__trigger {
9
+ display: inline-block;
10
+ }
11
+
12
+ .w-popover__body {
13
+ position: absolute;
14
+ z-index: 1000;
15
+ background-color: var(--color-popover-bg);
16
+ border-radius: var(--radius-lg);
17
+ box-shadow: var(--shadow-float);
18
+ opacity: 0;
19
+ transition: opacity 0.2s ease;
20
+
21
+ &--active {
22
+ opacity: 1;
23
+ }
24
+ }
25
+
26
+ .w-popover__content {
27
+ padding: var(--spacing-md) var(--spacing-lg);
28
+ font-size: var(--font-size-md);
29
+ color: var(--color-text-primary);
30
+ white-space: nowrap;
31
+ }
32
+
33
+ /* Arrow base */
34
+ .w-popover__arrow {
35
+ position: absolute;
36
+ width: $arrow-size;
37
+ height: $arrow-size;
38
+ background-color: var(--color-popover-bg);
39
+ transform: rotate(45deg);
40
+ z-index: 1;
41
+
42
+ /* top placement: arrow at bottom of body */
43
+ &--top {
44
+ bottom: -$arrow-size / 2;
45
+ left: 50%;
46
+ margin-left: -$arrow-size / 2;
47
+ }
48
+
49
+ /* bottom placement: arrow at top of body */
50
+ &--bottom {
51
+ top: -$arrow-size / 2;
52
+ left: 50%;
53
+ margin-left: -$arrow-size / 2;
54
+ }
55
+
56
+ /* left placement: arrow at right of body */
57
+ &--left {
58
+ right: -$arrow-size / 2;
59
+ top: 50%;
60
+ margin-top: -$arrow-size / 2;
61
+ }
62
+
63
+ /* right placement: arrow at left of body */
64
+ &--right {
65
+ left: -$arrow-size / 2;
66
+ top: 50%;
67
+ margin-top: -$arrow-size / 2;
68
+ }
69
+ }
@@ -0,0 +1,19 @@
1
+ <view class="w-popover">
2
+ <view class="w-popover__trigger" bindtap="handleTriggerTap">
3
+ <slot name="trigger" />
4
+ </view>
5
+ <view
6
+ wx:if="{{_visible}}"
7
+ class="w-popover__body {{_active ? 'w-popover__body--active' : ''}}"
8
+ style="{{_bodyStyle}}"
9
+ >
10
+ <view
11
+ wx:if="{{showArrow}}"
12
+ class="w-popover__arrow {{_arrowClass}}"
13
+ style="{{_arrowStyle}}"
14
+ ></view>
15
+ <view class="w-popover__content">
16
+ <slot />
17
+ </view>
18
+ </view>
19
+ </view>
@@ -0,0 +1,216 @@
1
+ const { QrCode, Ecc } = require('../../libs/qrcodegen');
2
+
3
+ const ECL_MAP = {
4
+ L: Ecc.LOW,
5
+ M: Ecc.MEDIUM,
6
+ Q: Ecc.QUARTILE,
7
+ H: Ecc.HIGH,
8
+ };
9
+
10
+ Component({
11
+ properties: {
12
+ value: {
13
+ type: String,
14
+ value: '',
15
+ },
16
+ size: {
17
+ type: Number,
18
+ value: 160,
19
+ },
20
+ color: {
21
+ type: String,
22
+ value: '#000000',
23
+ },
24
+ backgroundColor: {
25
+ type: String,
26
+ value: '#FFFFFF',
27
+ },
28
+ errorCorrectionLevel: {
29
+ type: String,
30
+ value: 'M',
31
+ },
32
+ padding: {
33
+ type: Number,
34
+ value: 12,
35
+ },
36
+ iconSrc: {
37
+ type: String,
38
+ value: '',
39
+ },
40
+ iconSize: {
41
+ type: Number,
42
+ value: 40,
43
+ },
44
+ iconBackgroundColor: {
45
+ type: String,
46
+ value: '#FFFFFF',
47
+ },
48
+ iconBorderRadius: {
49
+ type: Number,
50
+ value: 4,
51
+ },
52
+ },
53
+
54
+ data: {
55
+ _canvasSize: 0,
56
+ _tempImagePath: '',
57
+ },
58
+
59
+ lifetimes: {
60
+ attached() {
61
+ this._draw();
62
+ },
63
+ },
64
+
65
+ observers: {
66
+ 'value, size, color, backgroundColor, errorCorrectionLevel, padding, iconSrc, iconSize, iconBackgroundColor, iconBorderRadius'() {
67
+ this._draw();
68
+ },
69
+ },
70
+
71
+ methods: {
72
+ _draw() {
73
+ const { value, size, padding } = this.data;
74
+ if (!value) return;
75
+
76
+ const canvasSize = size + padding * 2;
77
+ // Reset image so canvas becomes visible for drawing
78
+ this.setData({ _canvasSize: canvasSize, _tempImagePath: '' });
79
+
80
+ wx.nextTick(() => {
81
+ this.createSelectorQuery()
82
+ .select('#qr-canvas')
83
+ .fields({ node: true, size: true })
84
+ .exec((res) => {
85
+ if (!res || !res[0] || !res[0].node) return;
86
+
87
+ const canvas = res[0].node;
88
+ const dpr = wx.getWindowInfo().pixelRatio || 2;
89
+ canvas.width = canvasSize * dpr;
90
+ canvas.height = canvasSize * dpr;
91
+ const ctx = canvas.getContext('2d');
92
+ ctx.scale(dpr, dpr);
93
+
94
+ this._renderQr(canvas, ctx, canvasSize);
95
+ });
96
+ });
97
+ },
98
+
99
+ _renderQr(canvas, ctx, canvasSize) {
100
+ const {
101
+ value,
102
+ size,
103
+ color,
104
+ backgroundColor,
105
+ padding,
106
+ errorCorrectionLevel,
107
+ iconSrc,
108
+ iconSize,
109
+ iconBackgroundColor,
110
+ iconBorderRadius,
111
+ } = this.data;
112
+
113
+ // Use HIGH error correction when icon is present
114
+ const eclKey = iconSrc ? 'H' : errorCorrectionLevel || 'M';
115
+ const ecl = ECL_MAP[eclKey] || ECL_MAP.M;
116
+
117
+ let qr;
118
+ try {
119
+ qr = QrCode.encodeText(value, ecl);
120
+ } catch (e) {
121
+ console.warn('[w-qr-code] encode failed:', e.message);
122
+ return;
123
+ }
124
+
125
+ const modules = qr.getModules();
126
+ const moduleCount = qr.size;
127
+ const cellSize = size / moduleCount;
128
+
129
+ // Clear and fill background
130
+ ctx.clearRect(0, 0, canvasSize, canvasSize);
131
+ ctx.fillStyle = backgroundColor;
132
+ ctx.fillRect(0, 0, canvasSize, canvasSize);
133
+
134
+ // Draw modules
135
+ ctx.fillStyle = color;
136
+ for (let y = 0; y < moduleCount; y++) {
137
+ for (let x = 0; x < moduleCount; x++) {
138
+ if (modules[y][x]) {
139
+ ctx.fillRect(
140
+ padding + x * cellSize,
141
+ padding + y * cellSize,
142
+ Math.ceil(cellSize),
143
+ Math.ceil(cellSize),
144
+ );
145
+ }
146
+ }
147
+ }
148
+
149
+ // Draw icon or export immediately
150
+ if (iconSrc) {
151
+ this._drawIcon(canvas, ctx, canvasSize, iconSize, iconBackgroundColor, iconBorderRadius);
152
+ } else {
153
+ this._toImage(canvas);
154
+ }
155
+ },
156
+
157
+ _drawIcon(canvas, ctx, canvasSize, iconSize, bgColor, borderRadius) {
158
+ const { iconSrc } = this.data;
159
+ const img = canvas.createImage();
160
+
161
+ img.onload = () => {
162
+ const iconPadding = 4;
163
+ const bgSize = iconSize + iconPadding * 2;
164
+ const bgX = (canvasSize - bgSize) / 2;
165
+ const bgY = (canvasSize - bgSize) / 2;
166
+
167
+ // Draw icon background with rounded corners
168
+ ctx.fillStyle = bgColor;
169
+ this._roundRect(ctx, bgX, bgY, bgSize, bgSize, borderRadius);
170
+ ctx.fill();
171
+
172
+ // Draw icon centered, maintain aspect ratio
173
+ const ratio = Math.min(iconSize / img.width, iconSize / img.height);
174
+ const drawW = img.width * ratio;
175
+ const drawH = img.height * ratio;
176
+ const drawX = (canvasSize - drawW) / 2;
177
+ const drawY = (canvasSize - drawH) / 2;
178
+
179
+ ctx.drawImage(img, drawX, drawY, drawW, drawH);
180
+ this._toImage(canvas);
181
+ };
182
+
183
+ img.onerror = () => {
184
+ console.warn('[w-qr-code] icon load failed:', iconSrc);
185
+ };
186
+
187
+ img.src = iconSrc;
188
+ },
189
+
190
+ _toImage(canvas) {
191
+ wx.canvasToTempFilePath(
192
+ {
193
+ canvas,
194
+ success: (res) => {
195
+ this.setData({ _tempImagePath: res.tempFilePath });
196
+ },
197
+ },
198
+ this,
199
+ );
200
+ },
201
+
202
+ _roundRect(ctx, x, y, w, h, r) {
203
+ ctx.beginPath();
204
+ ctx.moveTo(x + r, y);
205
+ ctx.arcTo(x + w, y, x + w, y + h, r);
206
+ ctx.arcTo(x + w, y + h, x, y + h, r);
207
+ ctx.arcTo(x, y + h, x, y, r);
208
+ ctx.arcTo(x, y, x + w, y, r);
209
+ ctx.closePath();
210
+ },
211
+
212
+ onTap() {
213
+ this.triggerEvent('click');
214
+ },
215
+ },
216
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared"
4
+ }
@@ -0,0 +1,8 @@
1
+ .w-qr-code {
2
+ display: inline-block;
3
+
4
+ &__canvas,
5
+ &__image {
6
+ display: block;
7
+ }
8
+ }
@@ -0,0 +1,16 @@
1
+ <view class="w-qr-code" bind:tap="onTap">
2
+ <canvas
3
+ type="2d"
4
+ id="qr-canvas"
5
+ class="w-qr-code__canvas"
6
+ style="width: {{_canvasSize}}px; height: {{_canvasSize}}px;"
7
+ wx:if="{{!_tempImagePath}}"
8
+ ></canvas>
9
+ <image
10
+ wx:if="{{_tempImagePath}}"
11
+ class="w-qr-code__image"
12
+ src="{{_tempImagePath}}"
13
+ style="width: {{_canvasSize}}px; height: {{_canvasSize}}px;"
14
+ show-menu-by-longpress
15
+ />
16
+ </view>
@@ -0,0 +1,38 @@
1
+ Component({
2
+ relations: {
3
+ '../radio-group/radio-group': {
4
+ type: 'ancestor',
5
+ },
6
+ },
7
+
8
+ properties: {
9
+ value: { type: null, value: '' },
10
+ disabled: { type: Boolean, value: false },
11
+ label: { type: String, value: '' },
12
+ },
13
+
14
+ data: {
15
+ _groupSize: '',
16
+ _groupDisabled: false,
17
+ _checked: false,
18
+ },
19
+
20
+ methods: {
21
+ _setGroupContext(ctx) {
22
+ this.setData({
23
+ _groupSize: ctx.size || '',
24
+ _groupDisabled: ctx.disabled || false,
25
+ _checked: ctx.currentValue === this.data.value,
26
+ });
27
+ },
28
+
29
+ handleTap() {
30
+ if (this.data.disabled || this.data._groupDisabled) return;
31
+ if (this.data._checked) return;
32
+ const parent = this.getRelationNodes('../radio-group/radio-group');
33
+ if (parent && parent.length > 0) {
34
+ parent[0]._handleChildChange(this.data.value);
35
+ }
36
+ },
37
+ },
38
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared"
4
+ }
@@ -0,0 +1,50 @@
1
+ .w-radio {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ gap: var(--spacing-sm);
5
+ }
6
+
7
+ .w-radio__dot {
8
+ width: var(--size-radio);
9
+ height: var(--size-radio);
10
+ border-radius: 50%;
11
+ border: 2rpx solid var(--color-separator);
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ flex-shrink: 0;
16
+ box-sizing: border-box;
17
+ transition: border-color 0.2s;
18
+ }
19
+
20
+ .w-radio--checked .w-radio__dot {
21
+ border-color: var(--color-radio-checked);
22
+ }
23
+
24
+ .w-radio__dot-inner {
25
+ width: calc(var(--size-radio) - 16rpx);
26
+ height: calc(var(--size-radio) - 16rpx);
27
+ border-radius: 50%;
28
+ background: var(--color-radio-checked);
29
+ opacity: 0;
30
+ transition: opacity 0.2s;
31
+ }
32
+
33
+ .w-radio--checked .w-radio__dot-inner {
34
+ opacity: 1;
35
+ }
36
+
37
+ .w-radio__label {
38
+ font-size: var(--font-size-md);
39
+ color: var(--color-text-primary);
40
+ line-height: 1.4;
41
+ }
42
+
43
+ .w-radio--size-small .w-radio__label {
44
+ font-size: var(--font-size-sm);
45
+ }
46
+
47
+ .w-radio--disabled {
48
+ opacity: 0.4;
49
+ pointer-events: none;
50
+ }
@@ -0,0 +1,12 @@
1
+ <view
2
+ class="w-radio {{_checked ? 'w-radio--checked' : ''}} {{(disabled || _groupDisabled) ? 'w-radio--disabled' : ''}} w-radio--size-{{_groupSize || 'medium'}}"
3
+ bindtap="handleTap"
4
+ >
5
+ <view class="w-radio__dot">
6
+ <view class="w-radio__dot-inner"></view>
7
+ </view>
8
+ <view class="w-radio__label">
9
+ <text wx:if="{{label}}">{{label}}</text>
10
+ <slot wx:else></slot>
11
+ </view>
12
+ </view>
@@ -0,0 +1,39 @@
1
+ Component({
2
+ relations: {
3
+ '../radio-group/radio-group': {
4
+ type: 'ancestor',
5
+ },
6
+ },
7
+
8
+ properties: {
9
+ value: { type: null, value: '' },
10
+ disabled: { type: Boolean, value: false },
11
+ label: { type: String, value: '' },
12
+ round: { type: Boolean, value: false },
13
+ },
14
+
15
+ data: {
16
+ _groupSize: '',
17
+ _groupDisabled: false,
18
+ _checked: false,
19
+ },
20
+
21
+ methods: {
22
+ _setGroupContext(ctx) {
23
+ this.setData({
24
+ _groupSize: ctx.size || '',
25
+ _groupDisabled: ctx.disabled || false,
26
+ _checked: ctx.currentValue === this.data.value,
27
+ });
28
+ },
29
+
30
+ handleTap() {
31
+ if (this.data.disabled || this.data._groupDisabled) return;
32
+ if (this.data._checked) return;
33
+ const parent = this.getRelationNodes('../radio-group/radio-group');
34
+ if (parent && parent.length > 0) {
35
+ parent[0]._handleChildChange(this.data.value);
36
+ }
37
+ },
38
+ },
39
+ });
@@ -0,0 +1,4 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared"
4
+ }