sard-uniapp 1.19.1 → 1.19.3

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 (278) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/components/accordion/README.md +91 -0
  3. package/components/accordion/accordion.vue +7 -0
  4. package/components/accordion-item/accordion-item.vue +9 -0
  5. package/components/action-sheet/README.md +85 -0
  6. package/components/action-sheet/action-sheet.vue +15 -0
  7. package/components/action-sheet/variables.scss +1 -1
  8. package/components/alert/README.md +74 -0
  9. package/components/alert/alert.vue +10 -0
  10. package/components/avatar/README.md +86 -0
  11. package/components/avatar/avatar.vue +8 -0
  12. package/components/back-top/README.md +134 -0
  13. package/components/back-top/back-top.vue +9 -0
  14. package/components/badge/README.md +95 -0
  15. package/components/badge/badge.vue +11 -0
  16. package/components/button/README.md +162 -0
  17. package/components/button/button.vue +46 -0
  18. package/components/calendar/README.md +94 -0
  19. package/components/calendar/calendar.vue +21 -2
  20. package/components/calendar-input/README.md +65 -0
  21. package/components/calendar-input/calendar-input.d.ts +3 -2
  22. package/components/calendar-input/calendar-input.vue +32 -0
  23. package/components/calendar-input/common.d.ts +2 -0
  24. package/components/calendar-popout/README.md +100 -0
  25. package/components/calendar-popout/calendar-popout.d.ts +12 -2
  26. package/components/calendar-popout/calendar-popout.vue +32 -1
  27. package/components/calendar-popout/common.d.ts +2 -0
  28. package/components/card/README.md +82 -0
  29. package/components/card/card.vue +9 -0
  30. package/components/cascader/README.md +117 -0
  31. package/components/cascader/cascader.vue +13 -0
  32. package/components/cascader-input/README.md +51 -0
  33. package/components/cascader-input/cascader-input.d.ts +2 -1
  34. package/components/cascader-input/cascader-input.vue +32 -6
  35. package/components/cascader-input/common.d.ts +2 -0
  36. package/components/cascader-input/common.js +1 -0
  37. package/components/cascader-popout/README.md +53 -0
  38. package/components/cascader-popout/cascader-popout.d.ts +1 -1
  39. package/components/cascader-popout/cascader-popout.vue +21 -2
  40. package/components/check-icon/variables.scss +1 -1
  41. package/components/checkbox/README.md +185 -0
  42. package/components/checkbox/checkbox.vue +17 -0
  43. package/components/checkbox/variables.scss +1 -1
  44. package/components/checkbox-group/checkbox-group.vue +15 -0
  45. package/components/checkbox-input/README.md +44 -0
  46. package/components/checkbox-input/checkbox-input.d.ts +1 -0
  47. package/components/checkbox-input/checkbox-input.vue +25 -2
  48. package/components/checkbox-input/common.d.ts +2 -0
  49. package/components/checkbox-input/common.js +5 -1
  50. package/components/checkbox-popout/README.md +52 -0
  51. package/components/checkbox-popout/checkbox-popout.vue +19 -0
  52. package/components/col/col.vue +7 -0
  53. package/components/collapse/README.md +45 -0
  54. package/components/collapse/collapse.vue +3 -0
  55. package/components/config/index.d.ts +46 -1
  56. package/components/config/index.js +37 -0
  57. package/components/count-down/README.md +97 -0
  58. package/components/count-down/count-down.vue +8 -0
  59. package/components/count-to/README.md +61 -0
  60. package/components/count-to/count-to.vue +7 -0
  61. package/components/crop-image/README.md +86 -0
  62. package/components/crop-image/crop-image.vue +15 -0
  63. package/components/datetime-picker/README.md +136 -0
  64. package/components/datetime-picker/datetime-picker.vue +14 -0
  65. package/components/datetime-picker-input/README.md +82 -0
  66. package/components/datetime-picker-input/common.d.ts +2 -0
  67. package/components/datetime-picker-input/common.js +1 -0
  68. package/components/datetime-picker-input/datetime-picker-input.d.ts +2 -1
  69. package/components/datetime-picker-input/datetime-picker-input.vue +26 -0
  70. package/components/datetime-picker-popout/README.md +77 -0
  71. package/components/datetime-picker-popout/datetime-picker-popout.d.ts +1 -1
  72. package/components/datetime-picker-popout/datetime-picker-popout.vue +21 -2
  73. package/components/datetime-range-picker/README.md +49 -0
  74. package/components/datetime-range-picker/datetime-range-picker.vue +15 -0
  75. package/components/datetime-range-picker-input/README.md +58 -0
  76. package/components/datetime-range-picker-input/common.d.ts +2 -0
  77. package/components/datetime-range-picker-input/common.js +1 -0
  78. package/components/datetime-range-picker-input/datetime-range-picker-input.d.ts +1 -0
  79. package/components/datetime-range-picker-input/datetime-range-picker-input.vue +27 -0
  80. package/components/datetime-range-picker-popout/README.md +53 -0
  81. package/components/datetime-range-picker-popout/datetime-range-picker-popout.vue +22 -2
  82. package/components/dialog/README.md +192 -0
  83. package/components/dialog/dialog.d.ts +1 -1
  84. package/components/dialog/dialog.vue +33 -0
  85. package/components/dialog-agent/dialog-agent.d.ts +1 -1
  86. package/components/dialog-agent/dialog-agent.vue +21 -0
  87. package/components/divider/README.md +80 -0
  88. package/components/divider/divider.vue +8 -0
  89. package/components/dropdown/README.md +168 -0
  90. package/components/dropdown/common.d.ts +7 -0
  91. package/components/dropdown/common.js +1 -0
  92. package/components/dropdown/dropdown.d.ts +1 -1
  93. package/components/dropdown/dropdown.vue +16 -1
  94. package/components/dropdown/variables.scss +1 -1
  95. package/components/dropdown-item/dropdown-item.vue +51 -4
  96. package/components/empty/README.md +71 -0
  97. package/components/empty/empty.vue +8 -0
  98. package/components/empty/variables.scss +1 -1
  99. package/components/fab/README.md +111 -0
  100. package/components/fab/fab.vue +18 -0
  101. package/components/floating-bubble/README.md +70 -0
  102. package/components/floating-bubble/floating-bubble.vue +11 -0
  103. package/components/floating-panel/README.md +78 -0
  104. package/components/floating-panel/floating-panel.vue +11 -0
  105. package/components/form/README.md +308 -0
  106. package/components/form/form.vue +19 -0
  107. package/components/form-item/form-item.vue +17 -0
  108. package/components/grid/README.md +140 -0
  109. package/components/grid/grid.vue +11 -0
  110. package/components/grid-item/grid-item.vue +15 -0
  111. package/components/icon/README.md +118 -0
  112. package/components/icon/common.d.ts +2 -0
  113. package/components/icon/icon.d.ts +1 -0
  114. package/components/icon/icon.vue +18 -3
  115. package/components/indexes/README.md +83 -0
  116. package/components/indexes/indexes.vue +7 -0
  117. package/components/indexes-anchor/indexes-anchor.vue +5 -0
  118. package/components/input/README.md +170 -0
  119. package/components/input/common.d.ts +1 -0
  120. package/components/input/index.scss +0 -20
  121. package/components/input/input.vue +71 -17
  122. package/components/input/variables.scss +2 -2
  123. package/components/keyboard/README.md +82 -0
  124. package/components/keyboard/keyboard.vue +7 -0
  125. package/components/layout/README.md +89 -0
  126. package/components/list/README.md +118 -0
  127. package/components/list/list.vue +8 -0
  128. package/components/list-item/list-item.vue +15 -0
  129. package/components/load-more/README.md +75 -0
  130. package/components/load-more/load-more.vue +11 -0
  131. package/components/loading/README.md +89 -0
  132. package/components/loading/loading.vue +13 -0
  133. package/components/lucky-draw/README.md +174 -0
  134. package/components/marquee/README.md +65 -0
  135. package/components/marquee/marquee.vue +7 -0
  136. package/components/menu/_README.md +61 -0
  137. package/components/navbar/README.md +123 -0
  138. package/components/navbar/navbar.vue +11 -0
  139. package/components/navbar-item/navbar-item.vue +10 -0
  140. package/components/notice-bar/README.md +135 -0
  141. package/components/notice-bar/notice-bar.vue +17 -0
  142. package/components/notify/README.md +118 -0
  143. package/components/notify/notify.vue +11 -0
  144. package/components/notify-agent/notify-agent.vue +12 -0
  145. package/components/overlay/README.md +56 -0
  146. package/components/overlay/overlay.vue +10 -0
  147. package/components/pagination/README.md +80 -0
  148. package/components/pagination/pagination.vue +15 -0
  149. package/components/password-input/README.md +87 -0
  150. package/components/password-input/password-input.vue +17 -0
  151. package/components/picker/README.md +115 -0
  152. package/components/picker/common.d.ts +1 -1
  153. package/components/picker/common.js +18 -6
  154. package/components/picker/picker.vue +40 -15
  155. package/components/picker-input/README.md +51 -0
  156. package/components/picker-input/common.d.ts +2 -0
  157. package/components/picker-input/common.js +2 -0
  158. package/components/picker-input/picker-input.d.ts +2 -1
  159. package/components/picker-input/picker-input.vue +24 -2
  160. package/components/picker-popout/README.md +51 -0
  161. package/components/picker-popout/picker-popout.d.ts +1 -1
  162. package/components/picker-popout/picker-popout.vue +24 -4
  163. package/components/popout/README.md +111 -0
  164. package/components/popout/common.d.ts +1 -0
  165. package/components/popout/popout.d.ts +1 -1
  166. package/components/popout/popout.vue +30 -0
  167. package/components/popout-input/README.md +55 -0
  168. package/components/popout-input/popout-input.vue +16 -0
  169. package/components/popout-input/variables.scss +1 -1
  170. package/components/popover/README.md +191 -0
  171. package/components/popover/popover.vue +15 -0
  172. package/components/popover-reference/popover-reference.vue +5 -0
  173. package/components/popup/README.md +67 -0
  174. package/components/popup/popup.vue +20 -0
  175. package/components/progress-bar/README.md +90 -0
  176. package/components/progress-bar/progress-bar.vue +13 -0
  177. package/components/progress-circle/README.md +75 -0
  178. package/components/progress-circle/progress-circle.vue +10 -0
  179. package/components/pull-down-refresh/README.md +100 -0
  180. package/components/pull-down-refresh/pull-down-refresh.d.ts +1 -1
  181. package/components/pull-down-refresh/pull-down-refresh.vue +11 -0
  182. package/components/qrcode/README.md +103 -0
  183. package/components/qrcode/common.d.ts +2 -0
  184. package/components/qrcode/qrcode.vue +71 -61
  185. package/components/radio/README.md +172 -0
  186. package/components/radio/radio.vue +13 -0
  187. package/components/radio/variables.scss +1 -1
  188. package/components/radio-group/radio-group.vue +16 -0
  189. package/components/radio-input/README.md +44 -0
  190. package/components/radio-input/common.d.ts +3 -1
  191. package/components/radio-input/common.js +5 -1
  192. package/components/radio-input/radio-input.d.ts +1 -0
  193. package/components/radio-input/radio-input.vue +26 -2
  194. package/components/radio-popout/README.md +52 -0
  195. package/components/radio-popout/common.d.ts +1 -1
  196. package/components/radio-popout/radio-popout.vue +20 -0
  197. package/components/rate/README.md +106 -0
  198. package/components/rate/rate.d.ts +1 -1
  199. package/components/rate/rate.vue +22 -0
  200. package/components/rate/variables.scss +1 -1
  201. package/components/result/README.md +66 -0
  202. package/components/result/result.vue +10 -0
  203. package/components/row/row.vue +7 -0
  204. package/components/scroll-spy/README.md +70 -0
  205. package/components/scroll-spy/scroll-spy.vue +13 -0
  206. package/components/search/README.md +117 -0
  207. package/components/search/search.vue +25 -0
  208. package/components/search/variables.scss +1 -1
  209. package/components/share-sheet/README.md +94 -0
  210. package/components/share-sheet/share-sheet.vue +20 -0
  211. package/components/share-sheet/variables.scss +1 -1
  212. package/components/sidebar/README.md +118 -0
  213. package/components/sidebar/sidebar.vue +10 -0
  214. package/components/sidebar-item/sidebar-item.vue +8 -0
  215. package/components/signature/README.md +99 -0
  216. package/components/signature/signature.vue +20 -0
  217. package/components/skeleton/README.md +128 -0
  218. package/components/skeleton/skeleton.vue +12 -0
  219. package/components/skeleton-avatar/skeleton-avatar.vue +9 -0
  220. package/components/skeleton-block/skeleton-block.vue +8 -0
  221. package/components/skeleton-paragraph/skeleton-paragraph.vue +9 -0
  222. package/components/skeleton-title/skeleton-title.vue +8 -0
  223. package/components/slider/README.md +140 -0
  224. package/components/slider/slider.vue +29 -0
  225. package/components/space/README.md +82 -0
  226. package/components/space/space.vue +9 -0
  227. package/components/status-bar/README.md +72 -0
  228. package/components/status-bar/status-bar.vue +6 -0
  229. package/components/step/step.vue +9 -1
  230. package/components/stepper/README.md +94 -0
  231. package/components/stepper/stepper.vue +24 -0
  232. package/components/stepper/variables.scss +1 -1
  233. package/components/steps/README.md +142 -0
  234. package/components/steps/steps.vue +15 -0
  235. package/components/style/README.md +20 -0
  236. package/components/style/variables-dark.scss +10 -6
  237. package/components/style/variables.scss +17 -11
  238. package/components/swipe-action/README.md +82 -0
  239. package/components/swipe-action/swipe-action.vue +7 -0
  240. package/components/swiper-dot/README.md +45 -0
  241. package/components/swiper-dot/swiper-dot.vue +9 -0
  242. package/components/switch/README.md +89 -0
  243. package/components/switch/switch.vue +18 -0
  244. package/components/tab/tab.vue +8 -0
  245. package/components/tabbar/README.md +111 -0
  246. package/components/tabbar/tabbar.vue +12 -0
  247. package/components/tabbar-item/tabbar-item.vue +12 -0
  248. package/components/tabbar-pit/README.md +41 -0
  249. package/components/tabbar-pit/tabbar-pit.vue +5 -0
  250. package/components/table/README.md +162 -0
  251. package/components/table/table.vue +7 -0
  252. package/components/table-cell/table-cell.vue +7 -0
  253. package/components/table-row/table-row.vue +5 -0
  254. package/components/tabs/README.md +113 -0
  255. package/components/tabs/tabs.vue +10 -0
  256. package/components/tag/README.md +96 -0
  257. package/components/tag/common.d.ts +1 -1
  258. package/components/tag/index.scss +5 -1
  259. package/components/tag/tag.vue +16 -2
  260. package/components/timeline/README.md +66 -0
  261. package/components/timeline/timeline.vue +4 -0
  262. package/components/timeline/variables.scss +1 -1
  263. package/components/timeline-item/timeline-item.vue +9 -0
  264. package/components/toast/README.md +111 -0
  265. package/components/toast/toast.vue +11 -0
  266. package/components/toast-agent/toast-agent.vue +11 -0
  267. package/components/tree/README.md +208 -0
  268. package/components/tree/tree.vue +21 -0
  269. package/components/tree/variables.scss +3 -3
  270. package/components/upload/README.md +154 -0
  271. package/components/upload/common.d.ts +1 -0
  272. package/components/upload/upload.d.ts +1 -1
  273. package/components/upload/upload.vue +67 -26
  274. package/package.json +74 -45
  275. package/use/useFormPopout.d.ts +1 -1
  276. package/use/useFormPopout.js +4 -1
  277. package/use/usePopoutInput.d.ts +2 -1
  278. package/use/usePopoutInput.js +7 -4
@@ -2,7 +2,7 @@
2
2
  <view :class="qrcodeClass" :style="qrcodeStyle">
3
3
  <view :class="bem.e('canvas-wrapper')">
4
4
  <canvas
5
- type="2d"
5
+ :class="canvasId"
6
6
  :width="canvasSize"
7
7
  :height="canvasSize"
8
8
  :style="{ width: canvasSize + 'px', height: canvasSize + 'px' }"
@@ -10,7 +10,12 @@
10
10
  :id="canvasId"
11
11
  ></canvas>
12
12
  </view>
13
- <image :src="dataURL" mode="aspectFit" :class="bem.e('image')" />
13
+ <image
14
+ :src="dataURL"
15
+ :show-menu-by-longpress="showMenuByLongpress"
16
+ mode="aspectFit"
17
+ :class="bem.e('image')"
18
+ />
14
19
  <slot></slot>
15
20
  </view>
16
21
  </template>
@@ -30,11 +35,22 @@ import {
30
35
  stringifyStyle,
31
36
  createBem,
32
37
  uniqid,
33
- qrcode,
34
- isApp,
35
- getNode
38
+ qrcode
36
39
  } from "../../utils";
37
40
  import { defaultQrcodeProps } from "./common";
41
+ /**
42
+ * @property {string} rootClass 组件根元素类名,默认值:-。
43
+ * @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
44
+ * @property {string} text 要编码的字符串数据,默认值:-。
45
+ * @property {'L' | 'M' | 'Q' | 'H'} ecl 错误纠错级别,默认值:'M'。
46
+ * @property {string} size 二维码呈现的大小,默认值:320rpx。
47
+ * @property {number} canvasSize 画板的大小,默认值:400。
48
+ * @property {string} color 二维码颜色,默认值:#000。
49
+ * @property {string} bgColor 二维码背景颜色,默认值:#fff。
50
+ * @property {number} quietZoneModules 安静区域模块数,默认值:2。
51
+ * @property {boolean} showMenuByLongpress 长按图片显示菜单(微信小程序),默认值:false。
52
+ * @property {string} icon 二维码中图片的地址,默认值:-。
53
+ */
38
54
  export default _defineComponent({
39
55
  ...{
40
56
  options: {
@@ -53,7 +69,9 @@ export default _defineComponent({
53
69
  canvasSize: { type: Number, required: false },
54
70
  color: { type: String, required: false },
55
71
  bgColor: { type: String, required: false },
56
- quietZoneModules: { type: Number, required: false }
72
+ quietZoneModules: { type: Number, required: false },
73
+ showMenuByLongpress: { type: Boolean, required: false },
74
+ icon: { type: String, required: false }
57
75
  }, defaultQrcodeProps),
58
76
  setup(__props, { expose: __expose }) {
59
77
  __expose();
@@ -62,14 +80,13 @@ export default _defineComponent({
62
80
  const instance = getCurrentInstance();
63
81
  const canvasId = uniqid();
64
82
  const contextRef = shallowRef();
65
- const canvasRef = shallowRef();
66
83
  const qrcodeMap = computed(() => {
67
84
  return qrcode(props.text, {
68
85
  ecl: props.ecl
69
86
  });
70
87
  });
71
88
  const dataURL = ref("");
72
- const drawQrcodeInApp = () => {
89
+ const drawQrcode = async () => {
73
90
  const context = contextRef.value;
74
91
  if (!context) {
75
92
  return;
@@ -94,76 +111,69 @@ export default _defineComponent({
94
111
  }
95
112
  });
96
113
  });
97
- context.draw();
98
- uni.canvasToTempFilePath({
99
- x: 0,
100
- y: 0,
101
- width: size,
102
- height: size,
103
- destWidth: size,
104
- destHeight: size,
105
- canvasId,
106
- success(res) {
107
- dataURL.value = res.tempFilePath;
108
- }
114
+ await drawIcon(context);
115
+ context.draw(false, () => {
116
+ uni.canvasToTempFilePath(
117
+ {
118
+ x: 0,
119
+ y: 0,
120
+ width: size,
121
+ height: size,
122
+ destWidth: size,
123
+ destHeight: size,
124
+ canvasId,
125
+ success(res) {
126
+ dataURL.value = res.tempFilePath;
127
+ },
128
+ fail(err) {
129
+ console.log("uni.canvasToTempFilePath fail", err);
130
+ }
131
+ },
132
+ instance
133
+ );
109
134
  });
110
135
  };
111
- const drawQrcodeInOthers = () => {
112
- const canvas = canvasRef.value;
113
- if (!canvas) {
114
- return;
136
+ const drawIcon = async (ctx) => {
137
+ if (props.icon) {
138
+ const iconInfo = await loadIcon(props.icon);
139
+ const size = props.canvasSize;
140
+ ctx.save();
141
+ ctx.beginPath();
142
+ ctx.drawImage(iconInfo.path, size * 0.4, size * 0.4, size * 0.2, size * 0.2);
143
+ ctx.restore();
115
144
  }
116
- const map = qrcodeMap.value;
117
- const size = props.canvasSize;
118
- canvas.width = size;
119
- canvas.height = size;
120
- const moduleSize = size / (map.length + props.quietZoneModules * 2);
121
- const margin = moduleSize * props.quietZoneModules;
122
- const context = canvas.getContext("2d");
123
- const path2D = context.createPath2D ? context.createPath2D() : canvas.createPath2D ? canvas.createPath2D() : new Path2D();
124
- map.forEach((row, rowIndex) => {
125
- row.forEach((col, colIndex) => {
126
- if (col === 1) {
127
- path2D.rect(
128
- colIndex * moduleSize + margin,
129
- rowIndex * moduleSize + margin,
130
- moduleSize,
131
- moduleSize
132
- );
145
+ };
146
+ const loadIcon = (path) => {
147
+ return new Promise((resolve, reject) => {
148
+ uni.getImageInfo({
149
+ src: path,
150
+ success(res) {
151
+ resolve(res);
152
+ },
153
+ fail(err) {
154
+ console.log("uni.getImageInfo fail", path);
155
+ console.log("uni.getImageInfo fail", err);
156
+ reject(err);
133
157
  }
134
158
  });
135
159
  });
136
- context.clearRect(0, 0, size, size);
137
- context.fillStyle = props.bgColor;
138
- context.fillRect(0, 0, size, size);
139
- context.fillStyle = props.color;
140
- context.fill(path2D);
141
- dataURL.value = canvas.toDataURL();
142
160
  };
143
161
  watch(
144
162
  [
145
163
  contextRef,
146
- canvasRef,
147
164
  qrcodeMap,
148
165
  () => props.canvasSize,
149
166
  () => props.color,
150
167
  () => props.bgColor,
151
- () => props.quietZoneModules
168
+ () => props.quietZoneModules,
169
+ () => props.icon
152
170
  ],
153
171
  () => {
154
- if (isApp) {
155
- drawQrcodeInApp();
156
- } else {
157
- drawQrcodeInOthers();
158
- }
172
+ drawQrcode();
159
173
  }
160
174
  );
161
175
  onMounted(async () => {
162
- if (isApp) {
163
- contextRef.value = uni.createCanvasContext(canvasId, instance);
164
- } else {
165
- canvasRef.value = await getNode(`#${canvasId}`, instance);
166
- }
176
+ contextRef.value = uni.createCanvasContext(canvasId, instance);
167
177
  });
168
178
  const qrcodeClass = computed(() => {
169
179
  return classNames(bem.b(), props.rootClass);
@@ -174,12 +184,12 @@ export default _defineComponent({
174
184
  height: props.size
175
185
  });
176
186
  });
177
- const __returned__ = { props, bem, instance, canvasId, contextRef, canvasRef, qrcodeMap, dataURL, drawQrcodeInApp, drawQrcodeInOthers, qrcodeClass, qrcodeStyle };
187
+ const __returned__ = { props, bem, instance, canvasId, contextRef, qrcodeMap, dataURL, drawQrcode, drawIcon, loadIcon, qrcodeClass, qrcodeStyle };
178
188
  return __returned__;
179
189
  }
180
190
  });
181
191
  </script>
182
192
 
183
193
  <style lang="scss">
184
- @import './index.scss';
194
+ @use './index.scss' as *;
185
195
  </style>
@@ -0,0 +1,172 @@
1
+ ---
2
+ nav: 组件
3
+ title: Radio
4
+ subtitle: 单选按钮
5
+ group: 表单组件
6
+ ---
7
+
8
+ ## 介绍
9
+
10
+ 在一组可选项中进行单一选择。
11
+
12
+ ## 引入
13
+
14
+ ```ts
15
+ import Radio from 'sard-uniapp/components/radio/radio.vue'
16
+ import RadioGroup from 'sard-uniapp/components/radio-group/radio-group.vue'
17
+ ```
18
+
19
+ ## 代码演示
20
+
21
+ ### 基础使用
22
+
23
+ 使用 `v-model` 绑定当前选中值。
24
+
25
+ @code('${DEMO_PATH}/radio/demo/Basic.vue')
26
+
27
+ ### 排列方向
28
+
29
+ 将 `direction` 属性设置为 `horizontal` 后,单选按钮组会变成水平排列。
30
+
31
+ @code('${DEMO_PATH}/radio/demo/Direction.vue')
32
+
33
+ ### 只读和禁用
34
+
35
+ 只读或禁用后不可点击。
36
+
37
+ @code('${DEMO_PATH}/radio/demo/DisabledReadOnly.vue')
38
+
39
+ ### 图标大小
40
+
41
+ 使用 `size` 属性设置图标大小。
42
+
43
+ @code('${DEMO_PATH}/radio/demo/Size.vue')
44
+
45
+ ### 图标颜色
46
+
47
+ 使用 `checked-color` 属性设置选中时的图标颜色。
48
+
49
+ @code('${DEMO_PATH}/radio/demo/Color.vue')
50
+
51
+ ### 图标类型
52
+
53
+ 设置 `type` 属性为 `record` 可以使图标变为圆点类型。
54
+
55
+ @code('${DEMO_PATH}/radio/demo/Type.vue')
56
+
57
+ ### 自定义图标
58
+
59
+ 如果内置的图标不满足需求,可以使用 `icon` 插槽设置为任意的图标。
60
+ 插槽接收`checked`属性表示当前的选中状态。
61
+
62
+ @code('${DEMO_PATH}/radio/demo/Icon.vue')
63
+
64
+ ### 自动渲染单选按钮
65
+
66
+ 使用 `options` 属性设置可选项。
67
+
68
+ @code('${DEMO_PATH}/radio/demo/GroupOptions.vue')
69
+
70
+ ### 自定义 UI
71
+
72
+ 如果只想使用单选的逻辑,并想自定义 UI,可以使用单选按钮组的 `custom` 插槽。
73
+
74
+ 这个插槽接收 `toggle`方法和 `value` 属性作为参数。`toggle` 用于选中指定的选项,`value` 用于判断选中状态。
75
+
76
+ @code('${DEMO_PATH}/radio/demo/Custom1.vue')
77
+
78
+ 结合 `list` 组件使用:
79
+
80
+ @code('${DEMO_PATH}/radio/demo/Custom2.vue')
81
+
82
+ 单选按钮组里面 `radio` 组件,会自动判断选中状态;可以给 `radio` 组件添加 `readonly` 属性以便将点击操作交给其他组件。
83
+
84
+ @code('${DEMO_PATH}/radio/demo/Custom3.vue')
85
+
86
+ ## API
87
+
88
+ ### RadioProps
89
+
90
+ | 属性 | 描述 | 类型 | 默认值 |
91
+ | ------------- | ------------------------------------ | -------------------- | -------- |
92
+ | root-class | 组件根元素类名 | string | - |
93
+ | root-style | 组件根元素样式 | StyleValue | - |
94
+ | checked | 是否选中 | boolean | false |
95
+ | value | 单选按钮的值,配合单选按钮组一起使用 | any | - |
96
+ | label | 单选按钮标签 | string | - |
97
+ | disabled | 禁用状态 | boolean | - |
98
+ | readonly | 只读状态 | boolean | - |
99
+ | size | 图标的尺寸 | string | - |
100
+ | type | 图标类型 | 'circle' \| 'record' | 'circle' |
101
+ | checked-color | 选中时图标的颜色 | string | - |
102
+
103
+ ### RadioSlots
104
+
105
+ | 插槽 | 描述 | 属性 |
106
+ | ------- | -------------- | -------------------- |
107
+ | default | 自定义默认内容 | - |
108
+ | icon | 自定义图标 | { checked: boolean } |
109
+
110
+ ### RadioEmits
111
+
112
+ | 事件 | 描述 | 类型 |
113
+ | ----- | ---------- | -------------------- |
114
+ | click | 点击时触发 | (event: any) => void |
115
+
116
+ ### RadioGroupProps
117
+
118
+ | 属性 | 描述 | 类型 | 默认值 |
119
+ | --------------------- | ------------------------------------- | -------------------------- | -------------------------------- |
120
+ | root-class | 组件根元素类名 | string | - |
121
+ | root-style | 组件根元素样式 | StyleValue | - |
122
+ | model-value (v-model) | 指定选中的选项 | any | - |
123
+ | disabled | 禁用状态 | boolean | - |
124
+ | readonly | 只读状态 | boolean | - |
125
+ | size | 图标的尺寸 | string | - |
126
+ | type | 图标类型 | 'circle' \| 'record' | 'circle' |
127
+ | checked-color | 选中时图标的颜色 | string | - |
128
+ | direction | 排列方向 | 'horizontal' \| 'vertical' | 'vertical' |
129
+ | validate-event | 是否触发表单验证 | boolean | true |
130
+ | options | 自动设置单选按钮 | RadioGroupOption[] | - |
131
+ | option-keys | 自定义 options 的 label、value 的字段 | RadioGroupOptionKeys | {label: 'label', value: 'value'} |
132
+
133
+ ### RadioGroupOption
134
+
135
+ ```ts
136
+ export type RadioGroupOption =
137
+ | {
138
+ [key: PropertyKey]: any
139
+ }
140
+ | string
141
+ | number
142
+ | boolean
143
+ ```
144
+
145
+ ### RadioGroupOptionKeys
146
+
147
+ ```ts
148
+ export interface RadioGroupOptionKeys {
149
+ label?: string
150
+ value?: string
151
+ }
152
+ ```
153
+
154
+ ### RadioGroupSlots
155
+
156
+ | 插槽 | 描述 | 属性 |
157
+ | ------- | --------------------------------------------------------------------------------------------------------------- | -------------------------------------------- |
158
+ | default | 自定义默认内容 | - |
159
+ | custom | 同默认插槽,额外可以接收 `toggle` 方法切换选中状态,接收 `value` 属性判断选中状态;用于自定义单选按钮结构和样式 | { toggle: (value: any) => void, value: any } |
160
+
161
+ ### RadioGroupEmits
162
+
163
+ | 事件 | 描述 | 类型 |
164
+ | ------------------ | ---------------------- | -------------------- |
165
+ | update:model-value | 单选按钮组值改变时触发 | (value: any) => void |
166
+ | change | 单选按钮组值改变时触发 | (value: any) => void |
167
+
168
+ ## 主题定制
169
+
170
+ ### CSS 变量
171
+
172
+ @code('./variables.scss#variables')
@@ -24,6 +24,19 @@ import {
24
24
  } from "./common";
25
25
  import SarCheckIcon from "../check-icon/check-icon.vue";
26
26
  import { useFormContext } from "../form/common";
27
+ /**
28
+ * @property {string} rootClass 组件根元素类名,默认值:-。
29
+ * @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
30
+ * @property {boolean} checked 是否选中,默认值:false。
31
+ * @property {any} value 单选按钮的值,配合单选按钮组一起使用,默认值:-。
32
+ * @property {string} label 单选按钮标签,默认值:-。
33
+ * @property {boolean} disabled 禁用状态,默认值:-。
34
+ * @property {boolean} readonly 只读状态,默认值:-。
35
+ * @property {string} size 图标的尺寸,默认值:-。
36
+ * @property {'circle' | 'record'} type 图标类型,默认值:'circle'。
37
+ * @property {string} checkedColor 选中时图标的颜色,默认值:-。
38
+ * @event {(event: any) => void} click 点击时触发
39
+ */
27
40
  export default _defineComponent({
28
41
  components: {
29
42
  SarCheckIcon,
@@ -5,7 +5,7 @@ page,
5
5
  --sar-radio-group-row-gap: 16rpx;
6
6
 
7
7
  --sar-radio-icon-font-size: 40rpx;
8
- --sar-radio-icon-color: var(--sar-quaternary-color);
8
+ --sar-radio-icon-color: var(--sar-fourth-color);
9
9
  --sar-radio-icon-checked-color: var(--sar-primary);
10
10
  --sar-radio-icon-disabled-color: var(--sar-disabled-color);
11
11
  --sar-radio-icon-transition-duration: var(--sar-duration);
@@ -40,6 +40,22 @@ import {
40
40
  } from "../../utils";
41
41
  import { useFormItemContext } from "../form/common";
42
42
  import SarRadio from "../radio/radio.vue";
43
+ /**
44
+ * @property {string} rootClass 组件根元素类名,默认值:-。
45
+ * @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
46
+ * @property {any} modelValue 指定选中的选项,默认值:-。
47
+ * @property {boolean} disabled 禁用状态,默认值:-。
48
+ * @property {boolean} readonly 只读状态,默认值:-。
49
+ * @property {string} size 图标的尺寸,默认值:-。
50
+ * @property {'circle' | 'record'} type 图标类型,默认值:'circle'。
51
+ * @property {string} checkedColor 选中时图标的颜色,默认值:-。
52
+ * @property {'horizontal' | 'vertical'} direction 排列方向,默认值:'vertical'。
53
+ * @property {boolean} validateEvent 是否触发表单验证,默认值:true。
54
+ * @property {RadioGroupOption[]} options 自动设置单选按钮,默认值:-。
55
+ * @property {RadioGroupOptionKeys} optionKeys 自定义 options 的 label、value 的字段,默认值:{label: 'label', value: 'value'}。
56
+ * @event {(value: any) => void} update 单选按钮组值改变时触发
57
+ * @event {(value: any) => void} change 单选按钮组值改变时触发
58
+ */
43
59
  export default _defineComponent({
44
60
  components: {
45
61
  SarRadio,
@@ -0,0 +1,44 @@
1
+ ---
2
+ nav: 组件
3
+ title: RadioInput
4
+ subtitle: 单选输入框
5
+ group: 表单组件
6
+ version: 1.3+
7
+ ---
8
+
9
+ ## 介绍
10
+
11
+ 组合了单选弹出框、列表、输入框组件,实现了在弹出框中单选的功能。
12
+
13
+ ## 引入
14
+
15
+ ```ts
16
+ import RadioInput from 'sard-uniapp/components/radio-input/radio-input.vue'
17
+ ```
18
+
19
+ ## 代码演示
20
+
21
+ ### 基础使用
22
+
23
+ 通过 `title` 和 `placeholder` 属性设置弹出框标题和输入框占位文本,
24
+ 通过 `options` 属性设置可选项。
25
+
26
+ @code('${DEMO_PATH}/radio-input/demo/Basic.vue')
27
+
28
+ ## API
29
+
30
+ ### RadioInputProps
31
+
32
+ 继承 [`RadioPopoutProps`](./radio-popout#RadioPopoutProps) 并有以下额外属性:
33
+
34
+ | 属性 | 描述 | 类型 | 默认值 |
35
+ | --------------------------------- | ---------------------- | ---------- | --------------- |
36
+ | root-class | 弹出式输入框根元素类名 | string | - |
37
+ | root-style | 弹出式输入框根元素样式 | StyleValue | - |
38
+ | clearable | 是否显示清空按钮 | boolean | false |
39
+ | placeholder | 输入框占位符内容 | string | - |
40
+ | value-on-clear <sup>1.19.2+</sup> | 设置点击清除按钮后的值 | () => any | () => undefined |
41
+
42
+ ### RadioInputEmits
43
+
44
+ 继承 [`RadioPopoutEmits`](./radio-popout#RadioPopoutEmits)
@@ -3,11 +3,13 @@ import { type PopoutInputProps } from '../popout-input/common';
3
3
  import { type RadioPopoutEmits, type RadioPopoutProps } from '../radio-popout/common';
4
4
  export type RadioInputOption = RadioGroupOption;
5
5
  export interface RadioInputProps extends RadioPopoutProps, Omit<PopoutInputProps, 'modelValue'> {
6
+ valueOnClear?: () => any;
6
7
  }
7
8
  export declare const defaultRadioInputProps: () => {
9
+ valueOnClear: RadioInputProps["valueOnClear"];
8
10
  options: () => never[];
9
11
  validateEvent: boolean;
10
- type: RadioInputProps["type"];
12
+ type: RadioPopoutProps["type"];
11
13
  };
12
14
  export interface RadioInputEmits extends RadioPopoutEmits {
13
15
  }
@@ -1,2 +1,6 @@
1
1
  import { defaultRadioPopoutProps, } from '../radio-popout/common';
2
- export const defaultRadioInputProps = defaultRadioPopoutProps;
2
+ import { defaultConfig } from '../config';
3
+ export const defaultRadioInputProps = () => ({
4
+ ...defaultRadioPopoutProps(),
5
+ ...defaultConfig.radioInput,
6
+ });
@@ -10,6 +10,7 @@ declare const _default: import("vue").DefineComponent<RadioInputProps, {}, {}, {
10
10
  }>, {
11
11
  options: import("../radio/common").RadioGroupOption[];
12
12
  type: import("../radio/common").IconType;
13
+ valueOnClear: () => any;
13
14
  validateEvent: boolean;
14
15
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
16
  export default _default;
@@ -37,8 +37,31 @@ import { defaultOptionKeys } from "../radio/common";
37
37
  import {
38
38
  defaultRadioInputProps
39
39
  } from "./common";
40
- import { getMayPrimitiveOption, isNullish } from "../../utils";
40
+ import { getMayPrimitiveOption, isEmptyBinding, isNullish } from "../../utils";
41
41
  import { usePopoutInput } from "../../use";
42
+ /**
43
+ * @property {string} rootClass 弹出式输入框根元素类名,默认值:-。
44
+ * @property {StyleValue} rootStyle 弹出式输入框根元素样式,默认值:-。
45
+ * @property {any} modelValue 指定选中的选项,默认值:-。
46
+ * @property {boolean} disabled 禁用状态,默认值:-。
47
+ * @property {boolean} readonly 只读状态,默认值:-。
48
+ * @property {string} size 图标的尺寸,默认值:-。
49
+ * @property {'circle' | 'record'} type 图标类型,默认值:'circle'。
50
+ * @property {string} checkedColor 选中时图标的颜色,默认值:-。
51
+ * @property {'horizontal' | 'vertical'} direction 排列方向,默认值:'vertical'。
52
+ * @property {boolean} validateEvent 是否触发表单验证,默认值:true。
53
+ * @property {RadioGroupOption[]} options 自动设置单选按钮,默认值:-。
54
+ * @property {RadioGroupOptionKeys} optionKeys 自定义 options 的 label、value 的字段,默认值:{label: 'label', value: 'value'}。
55
+ * @property {string} popoutClass 弹窗框根元素类名,默认值:-。
56
+ * @property {StyleValue} popoutStyle 弹窗框根元素样式,默认值:-。
57
+ * @property {boolean} visible 是否显示弹出框,默认值:-。
58
+ * @property {string} title 弹出框标题,默认值:-。
59
+ * @property {boolean} clearable 是否显示清空按钮,默认值:false。
60
+ * @property {string} placeholder 输入框占位符内容,默认值:-。
61
+ * @property {() => any} valueOnClear 设置点击清除按钮后的值,默认值:() => undefined。
62
+ * @event {(visible: boolean) => void} update 弹出框显隐时触发
63
+ * @event {(value: any | undefined) => void} change 单选输入组件值改变时触发
64
+ */
42
65
  export default _defineComponent({
43
66
  components: {
44
67
  SarPopoutInput,
@@ -52,6 +75,7 @@ export default _defineComponent({
52
75
  },
53
76
  __name: "radio-input",
54
77
  props: _mergeDefaults({
78
+ valueOnClear: { type: Function, required: false },
55
79
  visible: { type: Boolean, required: false },
56
80
  title: { type: String, required: false },
57
81
  popoutClass: { type: String, required: false },
@@ -89,7 +113,7 @@ export default _defineComponent({
89
113
  return isNullish(option) ? "" : getMayPrimitiveOption(option, optionKeys.label);
90
114
  }
91
115
  function getInputValue() {
92
- if (isNullish(innerValue.value) || innerValue.value.length === 0) {
116
+ if (isEmptyBinding(innerValue.value)) {
93
117
  return "";
94
118
  }
95
119
  return getOutletText(props.options, fieldKeys.value, innerValue.value);
@@ -0,0 +1,52 @@
1
+ ---
2
+ nav: 组件
3
+ title: RadioPopout
4
+ subtitle: 单选弹出框
5
+ group: 表单组件
6
+ version: 1.16+
7
+ ---
8
+
9
+ ## 介绍
10
+
11
+ 组合了单选框组、列表、弹出框组件,实现了在弹出框中单选的功能。
12
+
13
+ ## 引入
14
+
15
+ ```ts
16
+ import RadioPopout from 'sard-uniapp/components/radio-popout/radio-popout.vue'
17
+ ```
18
+
19
+ ## 代码演示
20
+
21
+ ### 基础使用
22
+
23
+ 使用 `v-model` 双向绑定当前值,使用 `v-model:visible` 控制弹出框显隐。
24
+
25
+ @code('${DEMO_PATH}/radio-popout/demo/Basic.vue')
26
+
27
+ ## API
28
+
29
+ ### RadioPopoutProps
30
+
31
+ 继承 [`RadioGroupProps`](./radio#RadioGroupProps) 并有以下额外属性:
32
+
33
+ | 属性 | 描述 | 类型 | 默认值 |
34
+ | ----------------- | ---------------- | ---------- | ------ |
35
+ | popout-class | 弹窗框根元素类名 | string | - |
36
+ | popout-style | 弹窗框根元素样式 | StyleValue | - |
37
+ | visible (v-model) | 是否显示弹出框 | boolean | - |
38
+ | title | 弹出框标题 | string | - |
39
+
40
+ ### RadioPopoutEmits
41
+
42
+ | 事件 | 描述 | 类型 |
43
+ | ------------------ | ------------------------ | --------------------------------- |
44
+ | update:model-value | 单选输入组件值改变时触发 | (value: any \| undefined) => void |
45
+ | change | 单选输入组件值改变时触发 | (value: any \| undefined) => void |
46
+ | update:visible | 弹出框显隐时触发 | (visible: boolean) => void |
47
+
48
+ ## 主题定制
49
+
50
+ ### CSS 变量
51
+
52
+ @code('./variables.scss#variables')
@@ -9,7 +9,7 @@ export interface RadioPopoutProps extends RadioGroupProps {
9
9
  export declare const defaultRadioPopoutProps: () => {
10
10
  options: () => never[];
11
11
  validateEvent: boolean;
12
- type: import("../radio-input").RadioInputProps["type"];
12
+ type: RadioPopoutProps["type"];
13
13
  };
14
14
  export interface RadioPopoutSlots {
15
15
  default?(props: Record<string, never>): any;
@@ -69,6 +69,26 @@ import {
69
69
  } from "./common";
70
70
  import { defaultOptionKeys } from "../radio/common";
71
71
  import { useScrollSide, useFormPopout } from "../../use";
72
+ /**
73
+ * @property {string} rootClass 组件根元素类名,默认值:-。
74
+ * @property {StyleValue} rootStyle 组件根元素样式,默认值:-。
75
+ * @property {any} modelValue 指定选中的选项,默认值:-。
76
+ * @property {boolean} disabled 禁用状态,默认值:-。
77
+ * @property {boolean} readonly 只读状态,默认值:-。
78
+ * @property {string} size 图标的尺寸,默认值:-。
79
+ * @property {'circle' | 'record'} type 图标类型,默认值:'circle'。
80
+ * @property {string} checkedColor 选中时图标的颜色,默认值:-。
81
+ * @property {'horizontal' | 'vertical'} direction 排列方向,默认值:'vertical'。
82
+ * @property {boolean} validateEvent 是否触发表单验证,默认值:true。
83
+ * @property {RadioGroupOption[]} options 自动设置单选按钮,默认值:-。
84
+ * @property {RadioGroupOptionKeys} optionKeys 自定义 options 的 label、value 的字段,默认值:{label: 'label', value: 'value'}。
85
+ * @property {string} popoutClass 弹窗框根元素类名,默认值:-。
86
+ * @property {StyleValue} popoutStyle 弹窗框根元素样式,默认值:-。
87
+ * @property {boolean} visible 是否显示弹出框,默认值:-。
88
+ * @property {string} title 弹出框标题,默认值:-。
89
+ * @event {(visible: boolean) => void} update 弹出框显隐时触发
90
+ * @event {(value: any | undefined) => void} change 单选输入组件值改变时触发
91
+ */
72
92
  export default _defineComponent({
73
93
  components: {
74
94
  SarPopout,