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,178 @@
1
+ @import '../../styles/iconfont.scss';
2
+
3
+ .w-tree {
4
+ position: relative;
5
+ }
6
+
7
+ /* Node */
8
+ .w-tree__node {
9
+ display: flex;
10
+ align-items: center;
11
+ min-height: var(--size-tree-node-height);
12
+ padding-right: var(--spacing-md);
13
+ box-sizing: border-box;
14
+ transition: background-color 0.2s;
15
+ }
16
+
17
+ .w-tree__node--hover {
18
+ background-color: var(--color-press-overlay-light);
19
+ }
20
+
21
+ .w-tree__node--selected {
22
+ background-color: var(--color-tree-node-selected-bg);
23
+ }
24
+
25
+ .w-tree__node--selected .w-tree__label {
26
+ color: var(--color-brand);
27
+ font-weight: 500;
28
+ }
29
+
30
+ .w-tree__node--disabled {
31
+ opacity: 0.4;
32
+ }
33
+
34
+ /* Switcher */
35
+ .w-tree__switcher {
36
+ display: flex;
37
+ align-items: center;
38
+ justify-content: center;
39
+ width: 56rpx;
40
+ height: 56rpx;
41
+ flex-shrink: 0;
42
+ }
43
+
44
+ .w-tree__arrow {
45
+ font-size: 24rpx;
46
+ color: var(--color-text-secondary);
47
+ transition: transform 0.2s;
48
+ line-height: 1;
49
+ }
50
+
51
+ .w-tree__switcher--expanded .w-tree__arrow {
52
+ transform: rotate(90deg);
53
+ }
54
+
55
+ /* Loading spinner */
56
+ .w-tree__loading {
57
+ width: 24rpx;
58
+ height: 24rpx;
59
+ border: 3rpx solid var(--color-separator);
60
+ border-top-color: var(--color-brand);
61
+ border-radius: 50%;
62
+ animation: w-tree-spin 0.6s linear infinite;
63
+ }
64
+
65
+ @keyframes w-tree-spin {
66
+ to {
67
+ transform: rotate(360deg);
68
+ }
69
+ }
70
+
71
+ /* Checkbox */
72
+ .w-tree__checkbox {
73
+ display: flex;
74
+ align-items: center;
75
+ justify-content: center;
76
+ width: 48rpx;
77
+ height: 48rpx;
78
+ flex-shrink: 0;
79
+ margin-right: var(--spacing-xs);
80
+ }
81
+
82
+ .w-tree__checkbox-inner {
83
+ width: var(--size-checkbox);
84
+ height: var(--size-checkbox);
85
+ border: 2rpx solid var(--color-separator);
86
+ border-radius: 6rpx;
87
+ box-sizing: border-box;
88
+ transition:
89
+ background-color 0.2s,
90
+ border-color 0.2s;
91
+ position: relative;
92
+ }
93
+
94
+ .w-tree__checkbox--checked .w-tree__checkbox-inner {
95
+ background-color: var(--color-brand);
96
+ border-color: var(--color-brand);
97
+ }
98
+
99
+ .w-tree__checkbox--checked .w-tree__checkbox-inner::after {
100
+ content: '';
101
+ position: absolute;
102
+ top: 45%;
103
+ left: 50%;
104
+ width: 40%;
105
+ height: 20%;
106
+ border-left: 3rpx solid #fff;
107
+ border-bottom: 3rpx solid #fff;
108
+ transform: translate(-50%, -60%) rotate(-45deg);
109
+ }
110
+
111
+ .w-tree__checkbox--indeterminate .w-tree__checkbox-inner {
112
+ border-color: var(--color-brand);
113
+ }
114
+
115
+ .w-tree__checkbox--indeterminate .w-tree__checkbox-inner::after {
116
+ content: '';
117
+ position: absolute;
118
+ top: 50%;
119
+ left: 50%;
120
+ width: 50%;
121
+ height: 0;
122
+ border-bottom: 3rpx solid var(--color-brand);
123
+ transform: translate(-50%, -50%);
124
+ }
125
+
126
+ .w-tree__checkbox--disabled .w-tree__checkbox-inner {
127
+ opacity: 0.4;
128
+ }
129
+
130
+ /* Icon */
131
+ .w-tree__icon {
132
+ font-size: 32rpx;
133
+ color: var(--color-text-secondary);
134
+ margin-right: var(--spacing-xs);
135
+ flex-shrink: 0;
136
+ line-height: 1;
137
+ }
138
+
139
+ /* Label */
140
+ .w-tree__label {
141
+ flex: 1;
142
+ min-width: 0;
143
+ font-size: var(--font-size-md);
144
+ color: var(--color-text-primary);
145
+ overflow: hidden;
146
+ text-overflow: ellipsis;
147
+ white-space: nowrap;
148
+ }
149
+
150
+ /* Highlight */
151
+ .w-tree__highlight {
152
+ color: var(--color-brand);
153
+ font-weight: 600;
154
+ background-color: var(--color-tree-node-highlight-bg);
155
+ border-radius: 4rpx;
156
+ padding: 0 2rpx;
157
+ }
158
+
159
+ /* Suffix */
160
+ .w-tree__suffix {
161
+ font-size: var(--font-size-sm);
162
+ color: var(--color-text-secondary);
163
+ margin-left: var(--spacing-xs);
164
+ flex-shrink: 0;
165
+ }
166
+
167
+ /* Empty */
168
+ .w-tree__empty {
169
+ display: flex;
170
+ align-items: center;
171
+ justify-content: center;
172
+ padding: var(--spacing-xl) 0;
173
+ }
174
+
175
+ .w-tree__empty-text {
176
+ font-size: var(--font-size-md);
177
+ color: var(--color-text-placeholder);
178
+ }
@@ -0,0 +1,59 @@
1
+ <view class="w-tree">
2
+ <slot name="header"></slot>
3
+
4
+ <view wx:if="{{_visibleNodes.length === 0}}" class="w-tree__empty">
5
+ <text class="w-tree__empty-text">暂无数据</text>
6
+ </view>
7
+
8
+ <view
9
+ wx:for="{{_visibleNodes}}"
10
+ wx:key="key"
11
+ class="w-tree__node {{item.isSelected ? 'w-tree__node--selected' : ''}} {{item.disabled ? 'w-tree__node--disabled' : ''}}"
12
+ style="padding-left: {{item.paddingLeft}}rpx;"
13
+ data-key="{{item.key}}"
14
+ bindtap="handleNodeTap"
15
+ hover-class="{{item.disabled ? '' : 'w-tree__node--hover'}}"
16
+ hover-stay-time="70"
17
+ >
18
+ <!-- Switcher -->
19
+ <view
20
+ wx:if="{{!item.isLeaf}}"
21
+ class="w-tree__switcher {{item.isExpanded ? 'w-tree__switcher--expanded' : ''}}"
22
+ data-key="{{item.key}}"
23
+ catchtap="handleSwitcherTap"
24
+ >
25
+ <view wx:if="{{item.isLoading}}" class="w-tree__loading"></view>
26
+ <text wx:else class="w-tree__arrow iconfont icon-right"></text>
27
+ </view>
28
+ <view wx:else class="w-tree__switcher w-tree__switcher--leaf"></view>
29
+
30
+ <!-- Checkbox -->
31
+ <view
32
+ wx:if="{{checkable}}"
33
+ class="w-tree__checkbox {{item.isChecked ? 'w-tree__checkbox--checked' : ''}} {{item.isIndeterminate ? 'w-tree__checkbox--indeterminate' : ''}} {{item.disabled ? 'w-tree__checkbox--disabled' : ''}}"
34
+ data-key="{{item.key}}"
35
+ catchtap="handleCheckTap"
36
+ >
37
+ <view class="w-tree__checkbox-inner"></view>
38
+ </view>
39
+
40
+ <!-- Prefix icon -->
41
+ <text
42
+ wx:if="{{item.prefixIcon || item.icon}}"
43
+ class="w-tree__icon iconfont {{item.prefixIcon || item.icon}}"
44
+ ></text>
45
+
46
+ <!-- Label -->
47
+ <view class="w-tree__label">
48
+ <block wx:if="{{item.labelParts}}">
49
+ <text>{{item.labelParts[0]}}</text>
50
+ <text class="w-tree__highlight">{{item.labelParts[1]}}</text>
51
+ <text>{{item.labelParts[2]}}</text>
52
+ </block>
53
+ <text wx:else>{{item.label}}</text>
54
+ </view>
55
+
56
+ <!-- Suffix -->
57
+ <text wx:if="{{item.suffixText}}" class="w-tree__suffix">{{item.suffixText}}</text>
58
+ </view>
59
+ </view>
@@ -0,0 +1,260 @@
1
+ const formField = require('../../behaviors/formField');
2
+
3
+ Component({
4
+ behaviors: ['wx://form-field', formField],
5
+
6
+ options: {
7
+ multipleSlots: true,
8
+ },
9
+
10
+ relations: {
11
+ '../form-item/form-item': {
12
+ type: 'ancestor',
13
+ },
14
+ },
15
+
16
+ properties: {
17
+ value: { type: null, value: null },
18
+ data: { type: Array, value: [] },
19
+ mode: { type: String, value: 'half' },
20
+ title: { type: String, value: '' },
21
+ placeholder: { type: String, value: '请选择' },
22
+ disabled: { type: Boolean, value: false },
23
+ readonly: { type: Boolean, value: false },
24
+ clearable: { type: Boolean, value: false },
25
+ multiple: { type: Boolean, value: false },
26
+ checkable: { type: Boolean, value: false },
27
+ cascade: { type: Boolean, value: true },
28
+ checkStrategy: { type: String, value: 'all' },
29
+ showPath: { type: Boolean, value: false },
30
+ pathSeparator: { type: String, value: ' / ' },
31
+ maxTagCount: { type: Number, value: 0 },
32
+ filterable: { type: Boolean, value: false },
33
+ size: { type: String, value: '' },
34
+ status: { type: String, value: '' },
35
+ // Pass-through to tree
36
+ keyField: { type: String, value: 'key' },
37
+ labelField: { type: String, value: 'label' },
38
+ childrenField: { type: String, value: 'children' },
39
+ accordion: { type: Boolean, value: false },
40
+ showLine: { type: Boolean, value: false },
41
+ defaultExpandAll: { type: Boolean, value: false },
42
+ },
43
+
44
+ data: {
45
+ _visible: false,
46
+ _displayText: '',
47
+ _selectedTags: [],
48
+ _overflowCount: 0,
49
+ _searchPattern: '',
50
+ },
51
+
52
+ lifetimes: {
53
+ attached() {
54
+ this._syncDisplay();
55
+ },
56
+ },
57
+
58
+ observers: {
59
+ 'value, data'() {
60
+ this._syncDisplay();
61
+ },
62
+ },
63
+
64
+ methods: {
65
+ // ===== Form Integration =====
66
+
67
+ _getTree() {
68
+ return this.selectComponent('.w-tree-select__tree');
69
+ },
70
+
71
+ // ===== Display Sync =====
72
+
73
+ _syncDisplay() {
74
+ const {
75
+ value,
76
+ multiple,
77
+ checkable,
78
+ data,
79
+ showPath,
80
+ pathSeparator,
81
+ maxTagCount,
82
+ keyField,
83
+ labelField,
84
+ childrenField,
85
+ } = this.data;
86
+
87
+ if (!data || !data.length) {
88
+ this.setData({ _displayText: '', _selectedTags: [], _overflowCount: 0 });
89
+ return;
90
+ }
91
+
92
+ // Build a quick node map for display
93
+ const nodeMap = {};
94
+ const buildMap = (nodes, parentLabels) => {
95
+ if (!nodes) return;
96
+ nodes.forEach((n) => {
97
+ const key = String(n[keyField]);
98
+ const label = n[labelField] || '';
99
+ const path = [...parentLabels, label];
100
+ nodeMap[key] = { label, path };
101
+ if (n[childrenField]) {
102
+ buildMap(n[childrenField], path);
103
+ }
104
+ });
105
+ };
106
+ buildMap(data, []);
107
+
108
+ if (multiple || checkable) {
109
+ const vals = Array.isArray(value) ? value : [];
110
+ const allTags = vals.map((v) => {
111
+ const node = nodeMap[String(v)];
112
+ return {
113
+ value: v,
114
+ label: node ? (showPath ? node.path.join(pathSeparator) : node.label) : String(v),
115
+ };
116
+ });
117
+
118
+ let displayTags = allTags;
119
+ let overflow = 0;
120
+ if (maxTagCount > 0 && allTags.length > maxTagCount) {
121
+ displayTags = allTags.slice(0, maxTagCount);
122
+ overflow = allTags.length - maxTagCount;
123
+ }
124
+
125
+ this.setData({
126
+ _selectedTags: displayTags,
127
+ _overflowCount: overflow,
128
+ _displayText: '',
129
+ });
130
+ } else {
131
+ const node = value != null ? nodeMap[String(value)] : null;
132
+ const text = node ? (showPath ? node.path.join(pathSeparator) : node.label) : '';
133
+ this.setData({ _displayText: text, _selectedTags: [], _overflowCount: 0 });
134
+ }
135
+ },
136
+
137
+ _syncTreeState() {
138
+ const tree = this._getTree();
139
+ if (!tree) return;
140
+
141
+ const { value, multiple, checkable } = this.data;
142
+
143
+ if (checkable) {
144
+ const keys = Array.isArray(value) ? value.map(String) : [];
145
+ tree.setData({ checkedKeys: keys });
146
+ } else if (multiple) {
147
+ const keys = Array.isArray(value) ? value.map(String) : [];
148
+ tree.setData({ selectedKeys: keys });
149
+ } else {
150
+ const keys = value != null ? [String(value)] : [];
151
+ tree.setData({ selectedKeys: keys });
152
+ }
153
+ },
154
+
155
+ // ===== Tree Event Handlers =====
156
+
157
+ _readTreeValue() {
158
+ const tree = this._getTree();
159
+ if (!tree) return this.data.value;
160
+
161
+ if (this.data.checkable) {
162
+ return tree._getOutputCheckedKeys();
163
+ } else if (this.data.multiple) {
164
+ return Object.keys(tree.data._selectedKeySet).filter((k) => tree.data._selectedKeySet[k]);
165
+ } else {
166
+ const keys = Object.keys(tree.data._selectedKeySet).filter(
167
+ (k) => tree.data._selectedKeySet[k],
168
+ );
169
+ return keys.length ? keys[0] : null;
170
+ }
171
+ },
172
+
173
+ handleTreeSelect(e) {
174
+ const { keys } = e.detail;
175
+ if (this.data.multiple) {
176
+ this._pendingValue = keys;
177
+ } else {
178
+ this._pendingValue = keys.length ? keys[0] : null;
179
+ }
180
+ },
181
+
182
+ handleTreeCheck(e) {
183
+ const { keys } = e.detail;
184
+ this._pendingValue = keys;
185
+ },
186
+
187
+ // ===== Event Handlers =====
188
+
189
+ handleTap() {
190
+ if (this._isDisabled() || this.data.readonly) return;
191
+ this._pendingValue = undefined;
192
+ this.setData({ _visible: true, _searchPattern: '' });
193
+ // Tree sync deferred to afterenter when DOM is ready
194
+ this.triggerEvent('open');
195
+ },
196
+
197
+ handleDrawerAfterEnter() {
198
+ this._syncTreeState();
199
+ },
200
+
201
+ handleCancel() {
202
+ this.setData({ _visible: false, _searchPattern: '' });
203
+ this._pendingValue = undefined;
204
+ this.triggerEvent('cancel');
205
+ this.triggerEvent('close');
206
+ },
207
+
208
+ handleConfirm() {
209
+ const value = this._pendingValue !== undefined ? this._pendingValue : this._readTreeValue();
210
+ this._pendingValue = undefined;
211
+ this._emitValue(value);
212
+ this.triggerEvent('confirm', { value });
213
+ this.setData({ _visible: false, _searchPattern: '' });
214
+ this.triggerEvent('close');
215
+ },
216
+
217
+ handleTriggerClear() {
218
+ const emptyVal = this.data.multiple || this.data.checkable ? [] : null;
219
+ this._emitValue(emptyVal);
220
+ },
221
+
222
+ handleTagRemove(e) {
223
+ const removeVal = e.currentTarget.dataset.value;
224
+ const currentValue = Array.isArray(this.data.value) ? [...this.data.value] : [];
225
+ const idx = currentValue.indexOf(removeVal);
226
+ if (idx !== -1) {
227
+ currentValue.splice(idx, 1);
228
+ this._emitValue(currentValue);
229
+ }
230
+ },
231
+
232
+ handleSearchInput(e) {
233
+ this.setData({ _searchPattern: e.detail.value });
234
+ },
235
+
236
+ handleDrawerClose() {
237
+ this._pendingValue = undefined;
238
+ this.setData({ _visible: false, _searchPattern: '' });
239
+ this.triggerEvent('close');
240
+ },
241
+
242
+ // ===== Value Emission =====
243
+
244
+ _emitValue(value) {
245
+ const tree = this._getTree();
246
+ const nodes = [];
247
+ if (tree) {
248
+ const keys = Array.isArray(value) ? value : value != null ? [value] : [];
249
+ keys.forEach((k) => {
250
+ const node = tree._getNodeByKey(String(k));
251
+ if (node) nodes.push(node.raw);
252
+ });
253
+ }
254
+
255
+ this.triggerEvent('update:value', { value, nodes });
256
+
257
+ this._notifyChange();
258
+ },
259
+ },
260
+ });
@@ -0,0 +1,8 @@
1
+ {
2
+ "component": true,
3
+ "styleIsolation": "apply-shared",
4
+ "usingComponents": {
5
+ "w-tree": "../tree/tree",
6
+ "w-drawer": "../drawer/drawer"
7
+ }
8
+ }