hy-app 0.2.13 → 0.2.15

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 (223) hide show
  1. package/components/hy-action-sheet/hy-action-sheet.vue +81 -13
  2. package/components/hy-action-sheet/typing.d.ts +1 -3
  3. package/components/hy-address-picker/hy-address-picker.vue +109 -8
  4. package/components/hy-address-picker/index.scss +2 -2
  5. package/components/hy-address-picker/typing.d.ts +39 -30
  6. package/components/hy-avatar/hy-avatar.vue +78 -4
  7. package/components/hy-avatar/typing.d.ts +21 -16
  8. package/components/hy-back-top/hy-back-top.vue +86 -28
  9. package/components/hy-back-top/typing.d.ts +17 -12
  10. package/components/hy-badge/hy-badge.vue +114 -43
  11. package/components/hy-badge/typing.d.ts +20 -15
  12. package/components/hy-button/HyButton.docgen.js +6 -0
  13. package/components/hy-button/hy-button.vue +70 -77
  14. package/components/hy-button/props.ts +40 -41
  15. package/components/hy-calendar/hy-calendar.vue +290 -143
  16. package/components/hy-calendar/typing.d.ts +38 -31
  17. package/components/hy-card/hy-card.vue +139 -36
  18. package/components/hy-card/typing.d.ts +39 -28
  19. package/components/hy-cell/hy-cell.vue +131 -67
  20. package/components/hy-cell/typing.d.ts +6 -1
  21. package/components/hy-check-button/hy-check-button.vue +101 -32
  22. package/components/hy-check-button/typing.d.ts +26 -19
  23. package/components/hy-checkbox/hy-checkbox.vue +167 -78
  24. package/components/hy-checkbox/typing.d.ts +26 -19
  25. package/components/hy-code-input/hy-code-input.vue +101 -5
  26. package/components/hy-code-input/typing.d.ts +9 -0
  27. package/components/hy-config-provider/hy-config-provider.vue +44 -24
  28. package/components/hy-config-provider/typing.d.ts +0 -4
  29. package/components/hy-count-down/hy-count-down.vue +99 -62
  30. package/components/hy-count-down/typing.d.ts +18 -5
  31. package/components/hy-count-to/hy-count-to.vue +165 -113
  32. package/components/hy-count-to/typing.d.ts +15 -11
  33. package/components/hy-datetime-picker/hy-datetime-picker.vue +338 -232
  34. package/components/hy-datetime-picker/typing.d.ts +49 -39
  35. package/components/hy-divider/hy-divider.vue +128 -64
  36. package/components/hy-divider/typing.d.ts +16 -16
  37. package/components/hy-dropdown/hy-dropdown.vue +57 -19
  38. package/components/hy-dropdown/typing.d.ts +14 -14
  39. package/components/hy-dropdown-item/hy-dropdown-item.vue +34 -5
  40. package/components/hy-dropdown-item/typing.d.ts +13 -6
  41. package/components/hy-empty/hy-empty.vue +64 -6
  42. package/components/hy-empty/typing.d.ts +5 -0
  43. package/components/hy-float-button/hy-float-button.vue +117 -5
  44. package/components/hy-float-button/typing.d.ts +7 -0
  45. package/components/hy-folding-panel/hy-folding-panel.vue +87 -25
  46. package/components/hy-folding-panel/typing.d.ts +24 -15
  47. package/components/hy-grid/hy-grid.vue +95 -35
  48. package/components/hy-grid/typing.d.ts +24 -19
  49. package/components/hy-icon/hy-icon.vue +84 -6
  50. package/components/hy-icon/typing.d.ts +5 -0
  51. package/components/hy-image/hy-image.vue +105 -6
  52. package/components/hy-image/typing.d.ts +9 -0
  53. package/components/hy-input/hy-input.vue +277 -130
  54. package/components/hy-input/props.ts +13 -14
  55. package/components/hy-input/typing.d.ts +59 -38
  56. package/components/hy-line/hy-line.vue +65 -25
  57. package/components/hy-line-progress/hy-line-progress.vue +68 -35
  58. package/components/hy-list/hy-list.vue +127 -61
  59. package/components/hy-list/typing.d.ts +19 -12
  60. package/components/hy-loading/hy-loading.vue +79 -25
  61. package/components/hy-menu/hy-menu.vue +69 -45
  62. package/components/hy-menu/typing.d.ts +22 -15
  63. package/components/hy-modal/hy-modal.vue +91 -4
  64. package/components/hy-modal/typing.d.ts +11 -0
  65. package/components/hy-navbar/hy-navbar.vue +105 -25
  66. package/components/hy-navbar/typing.d.ts +25 -20
  67. package/components/hy-notice-bar/hy-notice-bar.vue +97 -19
  68. package/components/hy-notice-bar/typing.d.ts +22 -17
  69. package/components/hy-notify/hy-notify.vue +106 -54
  70. package/components/hy-number-step/hy-number-step.vue +211 -120
  71. package/components/hy-number-step/typing.d.ts +45 -28
  72. package/components/hy-overlay/hy-overlay.vue +60 -16
  73. package/components/hy-overlay/typing.d.ts +11 -6
  74. package/components/hy-pagination/hy-pagination.vue +94 -37
  75. package/components/hy-pagination/typing.d.ts +20 -11
  76. package/components/hy-picker/hy-picker.vue +225 -160
  77. package/components/hy-picker/typing.d.ts +51 -28
  78. package/components/hy-popover/hy-popover.vue +55 -7
  79. package/components/hy-popover/typing.d.ts +21 -1
  80. package/components/hy-popup/hy-popup.vue +164 -99
  81. package/components/hy-popup/typing.d.ts +11 -0
  82. package/components/hy-price/hy-price.vue +77 -30
  83. package/components/hy-price/typing.d.ts +10 -10
  84. package/components/hy-qrcode/hy-qrcode.vue +75 -5
  85. package/components/hy-qrcode/typing.d.ts +25 -16
  86. package/components/hy-radio/hy-radio.vue +169 -88
  87. package/components/hy-radio/typing.d.ts +29 -22
  88. package/components/hy-rate/hy-rate.vue +155 -104
  89. package/components/hy-rate/typing.d.ts +23 -16
  90. package/components/hy-read-more/hy-read-more.vue +83 -56
  91. package/components/hy-read-more/typing.d.ts +18 -11
  92. package/components/hy-scroll-list/hy-scroll-list.vue +69 -58
  93. package/components/hy-scroll-list/typing.d.ts +14 -7
  94. package/components/hy-search/hy-search.vue +168 -62
  95. package/components/hy-search/typing.d.ts +47 -26
  96. package/components/hy-signature/hy-signature.vue +354 -272
  97. package/components/hy-signature/typing.d.ts +65 -52
  98. package/components/hy-slider/hy-slider.vue +208 -160
  99. package/components/hy-slider/typing.d.ts +28 -17
  100. package/components/hy-steps/hy-steps.vue +125 -99
  101. package/components/hy-steps/typing.d.ts +21 -14
  102. package/components/hy-submit-bar/hy-submit-bar.vue +129 -48
  103. package/components/hy-submit-bar/typing.d.ts +30 -23
  104. package/components/hy-subsection/hy-subsection.vue +139 -96
  105. package/components/hy-subsection/typing.d.ts +23 -16
  106. package/components/hy-swipe-action/hy-swipe-action.vue +161 -135
  107. package/components/hy-swipe-action/typing.d.ts +26 -17
  108. package/components/hy-swiper/hy-swiper.vue +178 -73
  109. package/components/hy-swiper/typing.d.ts +37 -28
  110. package/components/hy-switch/hy-switch.vue +107 -60
  111. package/components/hy-switch/typing.d.ts +25 -18
  112. package/components/hy-tabs/hy-tabs.vue +170 -160
  113. package/components/hy-tabs/typing.d.ts +36 -22
  114. package/components/hy-tag/hy-tag.vue +133 -58
  115. package/components/hy-tag/typing.d.ts +26 -18
  116. package/components/hy-text/hy-text.vue +106 -6
  117. package/components/hy-text/typing.d.ts +31 -26
  118. package/components/hy-textarea/hy-textarea.vue +183 -89
  119. package/components/hy-textarea/typing.d.ts +41 -24
  120. package/components/hy-tooltip/hy-tooltip.vue +145 -101
  121. package/components/hy-tooltip/typing.d.ts +18 -13
  122. package/components/hy-transition/hy-transition.vue +48 -13
  123. package/components/hy-transition/typing.d.ts +17 -0
  124. package/components/hy-upload/hy-upload.vue +113 -148
  125. package/components/hy-upload/typing.d.ts +71 -71
  126. package/components/hy-warn/hy-warn.vue +79 -36
  127. package/components/hy-warn/typing.d.ts +18 -11
  128. package/components/hy-waterfall/hy-waterfall.vue +90 -77
  129. package/components/hy-watermark/hy-watermark.vue +82 -5
  130. package/components/hy-watermark/typing.d.ts +20 -20
  131. package/global.d.ts +39 -59
  132. package/package.json +5 -13
  133. package/utils/inspect.ts +3 -1
  134. package/web-types.json +1 -1
  135. package/component-helper.ts +0 -177
  136. package/components.json +0 -3287
  137. package/dist/attributes.json +0 -1
  138. package/dist/docs/components/hy-action-sheet/hy-action-sheet.md +0 -41
  139. package/dist/docs/components/hy-address-picker/hy-address-picker.md +0 -25
  140. package/dist/docs/components/hy-avatar/hy-avatar.md +0 -19
  141. package/dist/docs/components/hy-back-top/hy-back-top.md +0 -19
  142. package/dist/docs/components/hy-badge/hy-badge.md +0 -13
  143. package/dist/docs/components/hy-button/hy-button.md +0 -61
  144. package/dist/docs/components/hy-calendar/header.md +0 -17
  145. package/dist/docs/components/hy-calendar/hy-calendar.md +0 -27
  146. package/dist/docs/components/hy-calendar/month.md +0 -38
  147. package/dist/docs/components/hy-card/hy-card.md +0 -24
  148. package/dist/docs/components/hy-cell/hy-cell.md +0 -26
  149. package/dist/docs/components/hy-check-button/hy-check-button.md +0 -14
  150. package/dist/docs/components/hy-checkbox/hy-checkbox.md +0 -21
  151. package/dist/docs/components/hy-code-input/hy-code-input.md +0 -15
  152. package/dist/docs/components/hy-config-provider/hy-config-provider.md +0 -13
  153. package/dist/docs/components/hy-count-down/hy-count-down.md +0 -34
  154. package/dist/docs/components/hy-count-to/hy-count-to.md +0 -31
  155. package/dist/docs/components/hy-datetime-picker/hy-datetime-picker.md +0 -25
  156. package/dist/docs/components/hy-divider/hy-divider.md +0 -13
  157. package/dist/docs/components/hy-dropdown/hy-dropdown.md +0 -13
  158. package/dist/docs/components/hy-dropdown-item/hy-dropdown-item.md +0 -20
  159. package/dist/docs/components/hy-empty/hy-empty.md +0 -20
  160. package/dist/docs/components/hy-float-button/hy-float-button.md +0 -20
  161. package/dist/docs/components/hy-folding-panel/hy-folding-panel.md +0 -24
  162. package/dist/docs/components/hy-form/hy-form.md +0 -29
  163. package/dist/docs/components/hy-grid/hy-grid.md +0 -19
  164. package/dist/docs/components/hy-icon/hy-icon.md +0 -13
  165. package/dist/docs/components/hy-image/hy-image.md +0 -22
  166. package/dist/docs/components/hy-input/hy-input.md +0 -29
  167. package/dist/docs/components/hy-line/hy-line.md +0 -7
  168. package/dist/docs/components/hy-line-progress/hy-line-progress.md +0 -13
  169. package/dist/docs/components/hy-list/hy-list.md +0 -25
  170. package/dist/docs/components/hy-loading/hy-loading.md +0 -14
  171. package/dist/docs/components/hy-login/ThePhoneLogin.md +0 -20
  172. package/dist/docs/components/hy-login/TheUserLogin.md +0 -44
  173. package/dist/docs/components/hy-login/hy-login.md +0 -14
  174. package/dist/docs/components/hy-menu/hy-menu.md +0 -21
  175. package/dist/docs/components/hy-modal/hy-modal.md +0 -23
  176. package/dist/docs/components/hy-navbar/hy-navbar.md +0 -22
  177. package/dist/docs/components/hy-notice-bar/hy-column-notice.md +0 -20
  178. package/dist/docs/components/hy-notice-bar/hy-notice-bar.md +0 -14
  179. package/dist/docs/components/hy-notice-bar/hy-row-notice.md +0 -20
  180. package/dist/docs/components/hy-notify/hy-notify.md +0 -23
  181. package/dist/docs/components/hy-number-step/hy-number-step.md +0 -27
  182. package/dist/docs/components/hy-overlay/hy-overlay.md +0 -19
  183. package/dist/docs/components/hy-pagination/hy-pagination.md +0 -14
  184. package/dist/docs/components/hy-parse/hy-parse.md +0 -46
  185. package/dist/docs/components/hy-parse/node/node.md +0 -7
  186. package/dist/docs/components/hy-picker/hy-picker.md +0 -32
  187. package/dist/docs/components/hy-popover/hy-popover.md +0 -34
  188. package/dist/docs/components/hy-popup/hy-popup.md +0 -22
  189. package/dist/docs/components/hy-price/hy-price.md +0 -13
  190. package/dist/docs/components/hy-qrcode/hy-qrcode.md +0 -15
  191. package/dist/docs/components/hy-radio/hy-radio.md +0 -21
  192. package/dist/docs/components/hy-rate/hy-rate.md +0 -14
  193. package/dist/docs/components/hy-read-more/hy-read-more.md +0 -21
  194. package/dist/docs/components/hy-scroll-list/hy-scroll-list.md +0 -21
  195. package/dist/docs/components/hy-search/hy-search.md +0 -27
  196. package/dist/docs/components/hy-signature/hy-signature.md +0 -45
  197. package/dist/docs/components/hy-slider/hy-slider.md +0 -24
  198. package/dist/docs/components/hy-status-bar/hy-status-bar.md +0 -13
  199. package/dist/docs/components/hy-steps/hy-steps.md +0 -23
  200. package/dist/docs/components/hy-submit-bar/hy-submit-bar.md +0 -21
  201. package/dist/docs/components/hy-subsection/hy-subsection.md +0 -14
  202. package/dist/docs/components/hy-swipe-action/hy-swipe-action.md +0 -29
  203. package/dist/docs/components/hy-swiper/hy-swiper-indicator.md +0 -23
  204. package/dist/docs/components/hy-swiper/hy-swiper.md +0 -22
  205. package/dist/docs/components/hy-switch/hy-switch.md +0 -20
  206. package/dist/docs/components/hy-tabBar/hy-tabBar.md +0 -13
  207. package/dist/docs/components/hy-tabs/hy-tabs.md +0 -27
  208. package/dist/docs/components/hy-tag/hy-tag.md +0 -21
  209. package/dist/docs/components/hy-text/hy-text.md +0 -13
  210. package/dist/docs/components/hy-textarea/hy-textarea.md +0 -19
  211. package/dist/docs/components/hy-toast/hy-toast.md +0 -17
  212. package/dist/docs/components/hy-tooltip/hy-tooltip.md +0 -13
  213. package/dist/docs/components/hy-transition/hy-transition.md +0 -25
  214. package/dist/docs/components/hy-upload/hy-upload.md +0 -25
  215. package/dist/docs/components/hy-warn/hy-warn.md +0 -14
  216. package/dist/docs/components/hy-waterfall/hy-waterfall.md +0 -30
  217. package/dist/docs/components/hy-watermark/hy-watermark.md +0 -7
  218. package/dist/docs/components/message/TheMessage.md +0 -17
  219. package/dist/docs/components/yk-dialog/yk-dialog.md +0 -7
  220. package/dist/tags.json +0 -1
  221. package/dist/web-types.json +0 -1
  222. package/docgen.config.js +0 -14
  223. package/web-types.config.js +0 -7
@@ -16,11 +16,7 @@
16
16
  :class="iconClasses(item)"
17
17
  :style="iconWrapStyle(item)"
18
18
  >
19
- <slot
20
- name="icon"
21
- :iconColor="iconColor"
22
- :iconSize="addUnit(sizeType[size] ?? iconSize)"
23
- >
19
+ <slot name="icon" :iconColor="iconColor" :iconSize="addUnit(sizeType[size] ?? iconSize)">
24
20
  <HyIcon
25
21
  class="hy-radio__icon-wrap__icon"
26
22
  :name="IconConfig.CHECK_MASK"
@@ -35,16 +31,14 @@
35
31
  >
36
32
  <slot name="label" :record="item">
37
33
  <text
38
- :class="[
39
- 'hy-radio__text',
40
- disabled && 'hy-radio__label-wrap--disabled',
41
- ]"
34
+ :class="['hy-radio__text', disabled && 'hy-radio__label-wrap--disabled']"
42
35
  :style="{
43
36
  color: labelColor,
44
37
  fontSize: addUnit(sizeType[size] ?? labelSize),
45
38
  }"
46
- >{{ item[fieldNames.label] }}</text
47
39
  >
40
+ {{ item[fieldNames.label] }}
41
+ </text>
48
42
  </slot>
49
43
  </view>
50
44
  </view>
@@ -53,35 +47,124 @@
53
47
  </template>
54
48
 
55
49
  <script lang="ts">
50
+ /**
51
+ * 复选框组件一般用于需要多个选择的场景,该组件功能完整,使用方便
52
+ * @displayName hy-radio
53
+ */
54
+ defineOptions({})
56
55
  export default {
57
- name: "hy-radio",
56
+ name: 'hy-radio',
58
57
  options: {
59
58
  addGlobalClass: true,
60
59
  virtualHost: true,
61
- styleIsolation: "shared",
60
+ styleIsolation: 'shared',
62
61
  },
63
- };
62
+ }
64
63
  </script>
65
64
 
66
65
  <script setup lang="ts">
67
- import type IProps from "./typing";
68
- import type { CheckboxColumnsVo } from "../hy-check-button/typing";
69
- import defaultProps from "./props";
70
- import {
71
- computed,
72
- type CSSProperties,
73
- reactive,
74
- ref,
75
- toRefs,
76
- watch,
77
- } from "vue";
78
- import { addUnit, bem, error } from "../../utils";
79
- import { IconConfig } from "../../config";
66
+ import { computed, reactive, ref, toRefs, watch } from 'vue'
67
+ import type { CSSProperties, PropType } from 'vue'
68
+ import type { IRadioEmits } from './typing'
69
+ import type { CheckboxColumnsVo, IFieldNames } from '../hy-check-button/typing'
70
+ import { addUnit, bem, error } from '../../utils'
71
+ import { IconConfig } from '../../config'
80
72
 
81
73
  // 组件
82
- import HyIcon from "../hy-icon/hy-icon.vue";
74
+ import HyIcon from '../hy-icon/hy-icon.vue'
83
75
 
84
- const props = withDefaults(defineProps<IProps>(), defaultProps);
76
+ // const props = withDefaults(defineProps<IProps>(), defaultProps);
77
+ const props = defineProps({
78
+ /** 双向绑定值,数组类型 */
79
+ modelValue: {
80
+ type: [String, Number],
81
+ required: true,
82
+ },
83
+ /** 选择列表数据 */
84
+ columns: {
85
+ type: Array as unknown as PropType<Array<CheckboxColumnsVo>>,
86
+ default: [],
87
+ required: true,
88
+ },
89
+ /** 自定义接收columns的键 */
90
+ fieldNames: {
91
+ type: Object as unknown as PropType<IFieldNames>,
92
+ default: {
93
+ label: 'label',
94
+ value: 'value',
95
+ checked: 'checked',
96
+ },
97
+ },
98
+ /**
99
+ * 标签的大小
100
+ * @values small,medium,large
101
+ * */
102
+ size: {
103
+ type: String,
104
+ default: 'medium',
105
+ },
106
+ /**
107
+ * 标签的形状
108
+ * @values circle,square
109
+ * */
110
+ shape: {
111
+ type: String,
112
+ default: 'square',
113
+ },
114
+ /** 是否禁用 */
115
+ disabled: {
116
+ type: Boolean,
117
+ default: false,
118
+ },
119
+ /** 选中状态下的颜色 */
120
+ activeColor: String,
121
+ /** 未选中的颜色 */
122
+ inactiveColor: {
123
+ type: String,
124
+ default: '#c8c9cc',
125
+ },
126
+ /** 图标的大小,单位px */
127
+ iconSize: {
128
+ type: [String, Number],
129
+ default: '20',
130
+ },
131
+ /** 图标颜色 */
132
+ iconColor: String,
133
+ /**
134
+ * 勾选图标的对齐方式
135
+ * @values left,right
136
+ * */
137
+ iconPlacement: {
138
+ type: String,
139
+ default: 'left',
140
+ },
141
+ /** 竖向配列时,是否显示下划线 */
142
+ borderBottom: {
143
+ type: Boolean,
144
+ default: false,
145
+ },
146
+ /** label的字体大小,px单位 */
147
+ labelSize: [String, Number],
148
+ /** label的颜色 */
149
+ labelColor: String,
150
+ /** 是否禁止点击提示语选中复选框 */
151
+ labelDisabled: {
152
+ type: Boolean,
153
+ default: false,
154
+ },
155
+ /**
156
+ * 排列方式
157
+ * @values row,column
158
+ * */
159
+ placement: {
160
+ type: String,
161
+ default: 'row',
162
+ },
163
+ /** 定义需要用到的外部样式 */
164
+ customStyle: {
165
+ type: Object as PropType<CSSProperties>,
166
+ },
167
+ })
85
168
  const {
86
169
  modelValue,
87
170
  columns,
@@ -96,30 +179,28 @@ const {
96
179
  placement,
97
180
  iconColor,
98
181
  labelDisabled,
99
- } = toRefs(props);
100
- const emit = defineEmits(["change", "update:modelValue"]);
182
+ } = toRefs(props)
183
+ const emit = defineEmits<IRadioEmits>()
101
184
 
102
- const columns_1 = ref();
185
+ const columns_1 = ref()
103
186
  const sizeType: AnyObject = reactive({
104
187
  small: 14,
105
188
  medium: 18,
106
189
  large: 22,
107
- });
190
+ })
108
191
 
109
192
  watch(
110
193
  () => modelValue.value,
111
194
  (newValue) => {
112
195
  columns_1.value = columns.value.map((item: any) => {
113
- item[fieldNames.value.checked] =
114
- newValue === item[fieldNames.value.value];
115
- return item;
116
- });
196
+ item[fieldNames.value.checked] = newValue === item[fieldNames.value.value]
197
+ return item
198
+ })
117
199
  },
118
200
  { immediate: true },
119
- );
201
+ )
120
202
 
121
- const isDisabled = (disabledVal?: boolean): boolean =>
122
- disabled.value || !!disabledVal;
203
+ const isDisabled = (disabledVal?: boolean): boolean => disabled.value || !!disabledVal
123
204
 
124
205
  /**
125
206
  * @description icon颜色
@@ -128,55 +209,55 @@ const iconColorCom = computed(() => {
128
209
  return (check: boolean) => {
129
210
  if (disabled.value) {
130
211
  if (check) {
131
- return "#c8c9cc";
212
+ return '#c8c9cc'
132
213
  } else {
133
- return "#F5F5F5";
214
+ return '#F5F5F5'
134
215
  }
135
216
  } else {
136
- return iconColor.value || "#ffffff";
217
+ return iconColor.value || '#ffffff'
137
218
  }
138
- };
139
- });
219
+ }
220
+ })
140
221
  /**
141
222
  * @description 单选框样式
142
223
  * */
143
224
  const radioStyle = computed(() => {
144
- const style: CSSProperties = {};
145
- if (borderBottom.value && placement.value === "row") {
225
+ const style: CSSProperties = {}
226
+ if (borderBottom.value && placement.value === 'row') {
146
227
  error(
147
- "检测到您将borderBottom设置为true,需要同时将u-checkbox-group的placement设置为column才有效",
148
- );
228
+ '检测到您将borderBottom设置为true,需要同时将u-checkbox-group的placement设置为column才有效',
229
+ )
149
230
  }
150
231
  // 当父组件设置了显示下边框并且排列形式为纵向时,给内容和边框之间加上一定间隔
151
- if (borderBottom.value && placement.value === "column") {
152
- style.paddingBottom = "8px";
232
+ if (borderBottom.value && placement.value === 'column') {
233
+ style.paddingBottom = '8px'
153
234
  }
154
- return Object.assign(style, customStyle.value);
155
- });
235
+ return Object.assign(style, customStyle.value)
236
+ })
156
237
  const bemClass = computed(() => {
157
- return bem("radio-group", props, ["placement"]);
158
- });
238
+ return bem('radio-group', props, ['placement'])
239
+ })
159
240
 
160
241
  /**
161
242
  * @description 定义icon的Class类名
162
243
  * */
163
244
  const iconClasses = computed(() => {
164
245
  return (temp: CheckboxColumnsVo): string[] => {
165
- let classes: string[] = [];
246
+ let classes: string[] = []
166
247
  // 组件的形状
167
- classes.push("hy-radio__icon-wrap--" + shape.value);
248
+ classes.push('hy-radio__icon-wrap--' + shape.value)
168
249
  if (isDisabled(temp?.disabled)) {
169
- classes.push("hy-radio__icon-wrap--disabled");
250
+ classes.push('hy-radio__icon-wrap--disabled')
170
251
  }
171
252
  if (temp[fieldNames.value.checked]) {
172
- classes.push("hy-radio__icon-wrap--checked");
253
+ classes.push('hy-radio__icon-wrap--checked')
173
254
  if (isDisabled(temp?.disabled)) {
174
- classes.push("hy-radio__icon-wrap--disabled--checked");
255
+ classes.push('hy-radio__icon-wrap--disabled--checked')
175
256
  }
176
257
  }
177
- return classes;
178
- };
179
- });
258
+ return classes
259
+ }
260
+ })
180
261
 
181
262
  /**
182
263
  * @description 定义icon的样式
@@ -184,50 +265,50 @@ const iconClasses = computed(() => {
184
265
  const iconWrapStyle = computed(() => {
185
266
  return (temp: CheckboxColumnsVo): CSSProperties => {
186
267
  // checkbox的整体样式
187
- const style: CSSProperties = {};
268
+ const style: CSSProperties = {}
188
269
  style.backgroundColor =
189
270
  temp[fieldNames.value.checked] && !isDisabled(temp?.disabled)
190
271
  ? activeColor.value
191
272
  : !isDisabled(temp?.disabled)
192
- ? "#ffffff"
193
- : "";
273
+ ? '#ffffff'
274
+ : ''
194
275
  style.borderColor =
195
276
  temp[fieldNames.value.checked] && !isDisabled(temp?.disabled)
196
277
  ? activeColor.value
197
- : inactiveColor.value;
198
- style.width = addUnit(sizeType[size.value] ?? size.value);
199
- style.height = addUnit(sizeType[size.value] ?? size.value);
200
- return style;
201
- };
202
- });
278
+ : inactiveColor.value
279
+ style.width = addUnit(sizeType[size.value] ?? size.value)
280
+ style.height = addUnit(sizeType[size.value] ?? size.value)
281
+ return style
282
+ }
283
+ })
203
284
 
204
285
  /**
205
286
  * @description 点击图标
206
287
  * */
207
288
  const iconClickHandler = (e: Event, temp: CheckboxColumnsVo) => {
208
- e.stopPropagation();
289
+ e.stopPropagation()
209
290
  if (!isDisabled(temp?.disabled)) {
210
- setRadioCheckedStatus(temp);
291
+ setRadioCheckedStatus(temp)
211
292
  }
212
- };
293
+ }
213
294
  /**
214
295
  * @description 点击整体
215
296
  * */
216
297
  const wrapperClickHandler = (e: Event, temp: CheckboxColumnsVo) => {
217
- e.stopPropagation();
298
+ e.stopPropagation()
218
299
  if (!isDisabled(temp?.disabled) || !labelDisabled.value) {
219
- setRadioCheckedStatus(temp);
300
+ setRadioCheckedStatus(temp)
220
301
  }
221
- };
302
+ }
222
303
  /**
223
304
  * @description 点击label
224
305
  * */
225
306
  const labelClickHandler = (e: Event, temp: CheckboxColumnsVo) => {
226
- e.stopPropagation();
307
+ e.stopPropagation()
227
308
  if (!isDisabled(temp?.disabled) || !labelDisabled.value) {
228
- setRadioCheckedStatus(temp);
309
+ setRadioCheckedStatus(temp)
229
310
  }
230
- };
311
+ }
231
312
 
232
313
  /**
233
314
  * @description 执行函数改变状态传给父值
@@ -236,21 +317,21 @@ const setRadioCheckedStatus = (temp: CheckboxColumnsVo) => {
236
317
  // 将本组件标记为与原来相反的状态
237
318
  columns_1.value = columns_1.value.map((item) => {
238
319
  if (temp[fieldNames.value.value] === item[fieldNames.value.value]) {
239
- item[fieldNames.value.checked] = true;
320
+ item[fieldNames.value.checked] = true
240
321
  } else {
241
- item[fieldNames.value.checked] = false;
322
+ item[fieldNames.value.checked] = false
242
323
  }
243
- return item;
244
- });
245
- emit("change", temp);
246
- emit("update:modelValue", temp[fieldNames.value.value]);
324
+ return item
325
+ })
326
+ emit('change', temp)
327
+ emit('update:modelValue', temp[fieldNames.value.value])
247
328
  // 双向绑定
248
329
  // if (this.usedAlone) {
249
330
  // this.$emit('update:checked', this.isChecked)
250
331
  // }
251
- };
332
+ }
252
333
  </script>
253
334
 
254
335
  <style lang="scss" scoped>
255
- @import "./index.scss";
336
+ @import './index.scss';
256
337
  </style>
@@ -1,85 +1,92 @@
1
- import type { CSSProperties } from "vue";
2
- import { CheckboxColumnsVo, IFieldNames } from "../hy-check-button/typing";
1
+ import type { CSSProperties } from 'vue'
2
+ import { CheckboxColumnsVo, IFieldNames } from '../hy-check-button/typing'
3
3
 
4
4
  export default interface HyRadioProps {
5
5
  /**
6
6
  * @description 双向绑定值,数组类型
7
7
  * */
8
- modelValue: string | number;
8
+ modelValue: string | number
9
9
  /**
10
10
  * @description 接受数组值
11
11
  * */
12
- columns: CheckboxColumnsVo[];
12
+ columns: CheckboxColumnsVo[]
13
13
  /**
14
14
  * @description 自定义接收columns的键
15
15
  * */
16
- fieldNames?: IFieldNames;
16
+ fieldNames?: IFieldNames
17
17
  /**
18
18
  * @description checkbox组件的标示符
19
19
  * */
20
- name?: string;
20
+ name?: string
21
21
  /**
22
22
  * @description 形状,square为方形,circle为圆型
23
23
  * */
24
- shape?: HyApp.ShapeType;
24
+ shape?: HyApp.ShapeType
25
25
  /**
26
26
  * @description 整体的大小
27
27
  * */
28
- size?: HyApp.SizeType | string | number;
28
+ size?: HyApp.SizeType | string | number
29
29
  /**
30
30
  * @description 是否默认选中
31
31
  * */
32
- checkbox?: boolean;
32
+ checkbox?: boolean
33
33
  /**
34
34
  * @description 是否禁用
35
35
  * */
36
- disabled?: boolean;
36
+ disabled?: boolean
37
37
  /**
38
38
  * @description 选中状态下的颜色,如设置此值,将会覆盖parent的activeColor值
39
39
  * */
40
- activeColor?: string;
40
+ activeColor?: string
41
41
  /**
42
42
  * @description 未选中的颜色
43
43
  * */
44
- inactiveColor?: string;
44
+ inactiveColor?: string
45
45
  /**
46
46
  * @description 图标的大小,单位px
47
47
  * */
48
- iconSize?: string;
48
+ iconSize?: string
49
49
  /**
50
50
  * @description 图标颜色
51
51
  * */
52
- iconColor?: string;
52
+ iconColor?: string
53
53
  /**
54
54
  * @description label提示文字,因为nvue下,直接slot进来的文字,由于特殊的结构,无法修改样式
55
55
  * */
56
- label?: string;
56
+ label?: string
57
57
  /**
58
58
  * @description label的字体大小,px单位
59
59
  * */
60
- labelSize?: string | number;
60
+ labelSize?: string | number
61
61
  /**
62
62
  * @description label的颜色
63
63
  * */
64
- labelColor?: string;
64
+ labelColor?: string
65
65
  /**
66
66
  * @description 勾选图标的对齐方式,left-左边,right-右边
67
67
  * */
68
- iconPlacement?: HyApp.LeftRightType;
68
+ iconPlacement?: HyApp.LeftRightType
69
69
  /**
70
70
  * @description 竖向配列时,是否显示下划线
71
71
  * */
72
- borderBottom?: boolean;
72
+ borderBottom?: boolean
73
73
  /**
74
74
  * @description 是否禁止点击提示语选中复选框
75
75
  * */
76
- labelDisabled?: boolean;
76
+ labelDisabled?: boolean
77
77
  /**
78
78
  * @description 定义需要用到的外部样式
79
79
  * */
80
- customStyle?: CSSProperties;
80
+ customStyle?: CSSProperties
81
81
  /**
82
82
  * @description 布局方式,row-横向,column-纵向
83
83
  * */
84
- placement?: HyApp.DirectionType;
84
+ placement?: HyApp.DirectionType
85
+ }
86
+
87
+ export interface IRadioEmits {
88
+ /** 选择触发 */
89
+ (e: 'change', temp: CheckboxColumnsVo): void
90
+ /** 更新值触发 */
91
+ (e: 'update:modelValue', temp: any): void
85
92
  }