uview-pro 0.2.4 → 0.3.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 (162) hide show
  1. package/changelog.md +29 -0
  2. package/components/u-action-sheet/types.ts +2 -0
  3. package/components/u-action-sheet/u-action-sheet.vue +15 -4
  4. package/components/u-alert-tips/types.ts +2 -0
  5. package/components/u-alert-tips/u-alert-tips.vue +24 -9
  6. package/components/u-avatar/types.ts +2 -0
  7. package/components/u-avatar/u-avatar.vue +15 -5
  8. package/components/u-avatar-cropper/u-avatar-cropper.vue +13 -2
  9. package/components/u-back-top/types.ts +2 -5
  10. package/components/u-back-top/u-back-top.vue +27 -15
  11. package/components/u-badge/types.ts +2 -0
  12. package/components/u-badge/u-badge.vue +33 -15
  13. package/components/u-button/types.ts +2 -2
  14. package/components/u-button/u-button.vue +23 -10
  15. package/components/u-car-keyboard/types.ts +2 -0
  16. package/components/u-car-keyboard/u-car-keyboard.vue +14 -5
  17. package/components/u-card/types.ts +2 -0
  18. package/components/u-card/u-card.vue +25 -10
  19. package/components/u-cell-group/types.ts +2 -0
  20. package/components/u-cell-group/u-cell-group.vue +15 -5
  21. package/components/u-cell-item/types.ts +2 -0
  22. package/components/u-cell-item/u-cell-item.vue +24 -11
  23. package/components/u-checkbox/types.ts +2 -0
  24. package/components/u-checkbox/u-checkbox.vue +12 -13
  25. package/components/u-checkbox-group/types.ts +2 -0
  26. package/components/u-checkbox-group/u-checkbox-group.vue +1 -1
  27. package/components/u-circle-progress/types.ts +2 -0
  28. package/components/u-circle-progress/u-circle-progress.vue +24 -9
  29. package/components/u-city-select/types.ts +2 -0
  30. package/components/u-city-select/u-city-select.vue +16 -4
  31. package/components/u-col/types.ts +2 -0
  32. package/components/u-col/u-col.vue +27 -8
  33. package/components/u-collapse/u-collapse.vue +8 -4
  34. package/components/u-collapse-item/u-collapse-item.vue +32 -27
  35. package/components/u-column-notice/types.ts +2 -0
  36. package/components/u-column-notice/u-column-notice.vue +16 -4
  37. package/components/u-count-down/types.ts +2 -0
  38. package/components/u-count-down/u-count-down.vue +20 -8
  39. package/components/u-count-to/types.ts +2 -0
  40. package/components/u-count-to/u-count-to.vue +25 -7
  41. package/components/u-divider/types.ts +2 -0
  42. package/components/u-divider/u-divider.vue +26 -10
  43. package/components/u-dropdown/types.ts +2 -0
  44. package/components/u-dropdown/u-dropdown.vue +48 -20
  45. package/components/u-dropdown-item/types.ts +2 -0
  46. package/components/u-dropdown-item/u-dropdown-item.vue +33 -41
  47. package/components/u-empty/types.ts +2 -0
  48. package/components/u-empty/u-empty.vue +20 -5
  49. package/components/u-field/types.ts +2 -0
  50. package/components/u-field/u-field.vue +18 -3
  51. package/components/u-form/types.ts +2 -0
  52. package/components/u-form/u-form.vue +20 -26
  53. package/components/u-form-item/types.ts +2 -0
  54. package/components/u-form-item/u-form-item.vue +67 -67
  55. package/components/u-full-screen/types.ts +2 -0
  56. package/components/u-full-screen/u-full-screen.vue +16 -2
  57. package/components/u-gap/types.ts +2 -0
  58. package/components/u-gap/u-gap.vue +15 -5
  59. package/components/u-grid/types.ts +2 -0
  60. package/components/u-grid/u-grid.vue +23 -25
  61. package/components/u-grid-item/types.ts +3 -3
  62. package/components/u-grid-item/u-grid-item.vue +43 -47
  63. package/components/u-icon/types.ts +0 -1
  64. package/components/u-icon/u-icon.vue +5 -3
  65. package/components/u-image/u-image.vue +13 -4
  66. package/components/u-index-anchor/types.ts +3 -3
  67. package/components/u-index-anchor/u-index-anchor.vue +18 -10
  68. package/components/u-index-list/u-index-list.vue +9 -12
  69. package/components/u-input/types.ts +2 -5
  70. package/components/u-input/u-input.vue +15 -6
  71. package/components/u-keyboard/u-keyboard.vue +13 -4
  72. package/components/u-lazy-load/u-lazy-load.vue +13 -2
  73. package/components/u-line/u-line.vue +13 -4
  74. package/components/u-line-progress/u-line-progress.vue +13 -4
  75. package/components/u-link/u-link.vue +13 -4
  76. package/components/u-loading/u-loading.vue +13 -4
  77. package/components/u-loading-popup/u-loading-popup.vue +14 -0
  78. package/components/u-loadmore/u-loadmore.vue +13 -2
  79. package/components/u-mask/types.ts +2 -5
  80. package/components/u-mask/u-mask.vue +21 -14
  81. package/components/u-message-input/u-message-input.vue +13 -2
  82. package/components/u-modal/u-modal.vue +13 -4
  83. package/components/u-navbar/u-navbar.vue +13 -2
  84. package/components/u-no-network/u-no-network.vue +13 -2
  85. package/components/u-notice-bar/u-notice-bar.vue +13 -3
  86. package/components/u-number-box/u-number-box.vue +13 -4
  87. package/components/u-number-keyboard/u-number-keyboard.vue +13 -4
  88. package/components/u-picker/u-picker.vue +13 -4
  89. package/components/u-popup/types.ts +2 -2
  90. package/components/u-popup/u-popup.vue +15 -5
  91. package/components/u-radio/types.ts +2 -0
  92. package/components/u-radio/u-radio.vue +26 -19
  93. package/components/u-radio-group/types.ts +2 -0
  94. package/components/u-radio-group/u-radio-group.vue +20 -32
  95. package/components/u-rate/types.ts +2 -0
  96. package/components/u-rate/u-rate.vue +20 -5
  97. package/components/u-read-more/types.ts +2 -0
  98. package/components/u-read-more/u-read-more.vue +23 -7
  99. package/components/u-root-portal/u-root-portal.vue +3 -1
  100. package/components/u-row/types.ts +2 -0
  101. package/components/u-row/u-row.vue +29 -11
  102. package/components/u-row-notice/types.ts +2 -0
  103. package/components/u-row-notice/u-row-notice.vue +16 -4
  104. package/components/u-safe-bottom/u-safe-bottom.vue +13 -2
  105. package/components/u-search/types.ts +2 -0
  106. package/components/u-search/u-search.vue +16 -5
  107. package/components/u-section/types.ts +2 -0
  108. package/components/u-section/u-section.vue +31 -12
  109. package/components/u-select/types.ts +2 -0
  110. package/components/u-select/u-select.vue +15 -5
  111. package/components/u-skeleton/types.ts +2 -0
  112. package/components/u-skeleton/u-skeleton.vue +14 -3
  113. package/components/u-slider/types.ts +2 -0
  114. package/components/u-slider/u-slider.vue +27 -19
  115. package/components/u-status-bar/u-status-bar.vue +13 -4
  116. package/components/u-steps/types.ts +2 -0
  117. package/components/u-steps/u-steps.vue +15 -3
  118. package/components/u-sticky/types.ts +2 -0
  119. package/components/u-sticky/u-sticky.vue +23 -7
  120. package/components/u-subsection/types.ts +2 -0
  121. package/components/u-subsection/u-subsection.vue +14 -3
  122. package/components/u-swipe-action/types.ts +2 -0
  123. package/components/u-swipe-action/u-swipe-action.vue +19 -3
  124. package/components/u-swiper/types.ts +2 -0
  125. package/components/u-swiper/u-swiper.vue +19 -2
  126. package/components/u-switch/types.ts +2 -0
  127. package/components/u-switch/u-switch.vue +15 -6
  128. package/components/u-tabbar/types.ts +2 -0
  129. package/components/u-tabbar/u-tabbar.vue +20 -3
  130. package/components/u-table/types.ts +2 -0
  131. package/components/u-table/u-table.vue +15 -3
  132. package/components/u-tabs/types.ts +2 -0
  133. package/components/u-tabs/u-tabs.vue +14 -3
  134. package/components/u-tabs-swiper/types.ts +2 -0
  135. package/components/u-tabs-swiper/u-tabs-swiper.vue +15 -3
  136. package/components/u-tag/types.ts +2 -0
  137. package/components/u-tag/u-tag.vue +22 -6
  138. package/components/u-td/types.ts +2 -0
  139. package/components/u-td/u-td.vue +14 -3
  140. package/components/u-text/u-text.vue +4 -2
  141. package/components/u-th/types.ts +2 -0
  142. package/components/u-th/u-th.vue +14 -3
  143. package/components/u-time-line/u-time-line.vue +17 -3
  144. package/components/u-time-line-item/types.ts +2 -0
  145. package/components/u-time-line-item/u-time-line-item.vue +15 -3
  146. package/components/u-toast/types.ts +2 -0
  147. package/components/u-toast/u-toast.vue +15 -8
  148. package/components/u-top-tips/types.ts +2 -0
  149. package/components/u-top-tips/u-top-tips.vue +20 -3
  150. package/components/u-tr/types.ts +4 -1
  151. package/components/u-tr/u-tr.vue +17 -2
  152. package/components/u-upload/types.ts +2 -0
  153. package/components/u-upload/u-upload.vue +14 -5
  154. package/components/u-verification-code/types.ts +2 -0
  155. package/components/u-verification-code/u-verification-code.vue +15 -3
  156. package/components/u-waterfall/types.ts +2 -0
  157. package/components/u-waterfall/u-waterfall.vue +15 -3
  158. package/libs/hooks/index.ts +2 -1
  159. package/libs/hooks/useCompRelation.ts +364 -0
  160. package/libs/index.ts +56 -39
  161. package/package.json +1 -1
  162. package/readme.md +6 -6
@@ -2,15 +2,18 @@
2
2
  <view
3
3
  @tap="onClick"
4
4
  class="u-cell"
5
- :class="{
6
- 'u-border-bottom': borderBottom,
7
- 'u-border-top': borderTop,
8
- 'u-col-center': center,
9
- 'u-cell--required': required
10
- }"
5
+ :class="[
6
+ {
7
+ 'u-border-bottom': borderBottom,
8
+ 'u-border-top': borderTop,
9
+ 'u-col-center': center,
10
+ 'u-cell--required': required
11
+ },
12
+ customClass
13
+ ]"
11
14
  hover-stay-time="150"
12
15
  :hover-class="hoverClass"
13
- :style="{ backgroundColor: bgColor }"
16
+ :style="$u.toStyle({ backgroundColor: bgColor }, customStyle)"
14
17
  >
15
18
  <u-icon
16
19
  :size="iconSize"
@@ -46,13 +49,23 @@
46
49
  </view>
47
50
  </template>
48
51
 
52
+ <script lang="ts">
53
+ export default {
54
+ name: 'u-cell-item',
55
+ options: {
56
+ addGlobalClass: true,
57
+ // #ifndef MP-TOUTIAO
58
+ virtualHost: true,
59
+ // #endif
60
+ styleIsolation: 'shared'
61
+ }
62
+ };
63
+ </script>
64
+
49
65
  <script setup lang="ts">
50
66
  import { computed, useSlots } from 'vue';
51
67
  import { CellItemProps } from './types';
52
-
53
- defineOptions({
54
- name: 'u-cell-item'
55
- });
68
+ import { $u } from '../..';
56
69
 
57
70
  /**
58
71
  * cellItem 单元格Item
@@ -1,5 +1,6 @@
1
1
  import { type ExtractPropTypes, type PropType } from 'vue';
2
2
  import type { Shape } from '../../types/global';
3
+ import { baseProps } from '../common/props';
3
4
 
4
5
  /**
5
6
  * checkbox 复选框类型定义
@@ -8,6 +9,7 @@ import type { Shape } from '../../types/global';
8
9
  export type CheckboxValue = string | number | boolean;
9
10
 
10
11
  export const CheckboxProps = {
12
+ ...baseProps,
11
13
  /** checkbox的名称 */
12
14
  name: { type: [String, Number], default: '' },
13
15
  /** 形状,square为方形,circle为原型 */
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="u-checkbox" :style="[checkboxStyle]">
2
+ <view class="u-checkbox" :style="$u.toStyle(checkboxStyle, customStyle)" :class="customClass">
3
3
  <view class="u-checkbox__icon-wrap" @tap="toggle" :class="iconClass" :style="$u.toStyle(iconStyle)">
4
4
  <u-icon
5
5
  class="u-checkbox__icon-wrap__icon"
@@ -35,7 +35,7 @@ export default {
35
35
 
36
36
  <script setup lang="ts">
37
37
  import { computed } from 'vue';
38
- import { $u, useChildren, useParentEvents } from '../..';
38
+ import { $u, useChildren } from '../..';
39
39
  import { CheckboxProps } from './types';
40
40
 
41
41
  /**
@@ -57,7 +57,7 @@ const props = defineProps(CheckboxProps);
57
57
  const emit = defineEmits(['change', 'update:modelValue']);
58
58
 
59
59
  // 使用子组件Hook
60
- const { childId, parentExposed } = useChildren('u-checkbox', 'u-checkbox-group');
60
+ const { parentExposed } = useChildren('u-checkbox', 'u-checkbox-group');
61
61
 
62
62
  // 是否禁用,如果父组件u-checkbox-group禁用的话,将会忽略子组件的配置
63
63
  const isDisabled = computed(() => {
@@ -188,24 +188,23 @@ function setValue() {
188
188
  }
189
189
  }
190
190
 
191
- // 使用自动取消监听注册父组件事件
192
- useParentEvents(childId, {
193
- setChecked: data => {
194
- if (!isDisabled.value) {
195
- emit('update:modelValue', data.checked);
196
- if (data.checked !== props.modelValue) {
197
- emitEvent();
198
- }
191
+ // 设置组件的modelValue值
192
+ function setChecked(data: any) {
193
+ if (!isDisabled.value) {
194
+ emit('update:modelValue', data.checked);
195
+ if (data.checked !== props.modelValue) {
196
+ emitEvent();
199
197
  }
200
198
  }
201
- });
199
+ }
202
200
 
203
201
  defineExpose({
204
202
  isChecked: computed(() => props.modelValue),
205
203
  name: props.name,
206
204
  setValue,
207
205
  emitEvent,
208
- props
206
+ props,
207
+ setChecked
209
208
  });
210
209
  </script>
211
210
 
@@ -1,5 +1,6 @@
1
1
  import { type ExtractPropTypes, type PropType } from 'vue';
2
2
  import type { Shape } from '../../types/global';
3
+ import { baseProps } from '../common/props';
3
4
 
4
5
  /**
5
6
  * checkbox-group 复选框组类型定义
@@ -7,6 +8,7 @@ import type { Shape } from '../../types/global';
7
8
  */
8
9
 
9
10
  export const CheckboxGroupProps = {
11
+ ...baseProps,
10
12
  /** 最多能选中多少个checkbox */
11
13
  max: { type: Number, default: 999 },
12
14
  /** 是否禁用所有复选框 */
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="u-checkbox-group u-clearfix">
2
+ <view class="u-checkbox-group u-clearfix" :class="customClass" :style="$u.toStyle(customStyle)">
3
3
  <slot></slot>
4
4
  </view>
5
5
  </template>
@@ -1,11 +1,13 @@
1
1
  import { type ExtractPropTypes, type PropType } from 'vue';
2
2
  import type { ThemeType } from '../../types/global';
3
+ import { baseProps } from '../common/props';
3
4
 
4
5
  /**
5
6
  * circleProgress 环形进度条 Props
6
7
  * @description 展示操作或任务的当前进度,比如上传文件,是一个圆形的进度条。注意:此组件的percent值只能动态增加,不能动态减少。
7
8
  */
8
9
  export const CircleProgressProps = {
10
+ ...baseProps,
9
11
  /** 圆环进度百分比值 */
10
12
  percent: {
11
13
  type: Number,
@@ -1,11 +1,17 @@
1
1
  <template>
2
2
  <view
3
3
  class="u-circle-progress"
4
- :style="{
5
- width: widthPx + 'px',
6
- height: widthPx + 'px',
7
- backgroundColor: bgColor
8
- }"
4
+ :class="customClass"
5
+ :style="
6
+ $u.toStyle(
7
+ {
8
+ width: widthPx + 'px',
9
+ height: widthPx + 'px',
10
+ backgroundColor: bgColor
11
+ },
12
+ customStyle
13
+ )
14
+ "
9
15
  >
10
16
  <!-- 支付宝小程序不支持canvas-id属性,必须用id属性 -->
11
17
  <canvas
@@ -30,15 +36,24 @@
30
36
  </view>
31
37
  </template>
32
38
 
39
+ <script lang="ts">
40
+ export default {
41
+ name: 'u-circle-progress',
42
+ options: {
43
+ addGlobalClass: true,
44
+ // #ifndef MP-TOUTIAO
45
+ virtualHost: true,
46
+ // #endif
47
+ styleIsolation: 'shared'
48
+ }
49
+ };
50
+ </script>
51
+
33
52
  <script setup lang="ts">
34
53
  import { ref, computed, watch, onMounted, getCurrentInstance } from 'vue';
35
54
  import { $u } from '../..';
36
55
  import { CircleProgressProps } from './types';
37
56
 
38
- defineOptions({
39
- name: 'u-circle-progress'
40
- });
41
-
42
57
  /**
43
58
  * circleProgress 环形进度条
44
59
  * @description 展示操作或任务的当前进度,比如上传文件,是一个圆形的进度条。注意:此组件的percent值只能动态增加,不能动态减少。
@@ -1,10 +1,12 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
+ import { baseProps } from '../common/props';
2
3
 
3
4
  /**
4
5
  * u-city-select 城市选择器 Props
5
6
  * @description 用于选择省、市、区三级行政区域,支持回显和自定义初始值。
6
7
  */
7
8
  export const CitySelectProps = {
9
+ ...baseProps,
8
10
  /** 控制弹窗显示与隐藏(v-model) */
9
11
  modelValue: { type: Boolean, default: false },
10
12
  /** 默认选中的省市区名称数组 */
@@ -1,6 +1,8 @@
1
1
  <template>
2
2
  <u-popup
3
3
  v-model="popupValue"
4
+ :class="customClass"
5
+ :style="$u.toStyle(customStyle)"
4
6
  mode="bottom"
5
7
  :popup="false"
6
8
  :mask="true"
@@ -89,16 +91,26 @@
89
91
  </u-popup>
90
92
  </template>
91
93
 
94
+ <script lang="ts">
95
+ export default {
96
+ name: 'u-city-select',
97
+ options: {
98
+ addGlobalClass: true,
99
+ // #ifndef MP-TOUTIAO
100
+ virtualHost: true,
101
+ // #endif
102
+ styleIsolation: 'shared'
103
+ }
104
+ };
105
+ </script>
106
+
92
107
  <script setup lang="ts">
93
108
  import { ref, computed, onMounted } from 'vue';
94
109
  import provinces from '../../libs/util/province';
95
110
  import citysData from '../../libs/util/city';
96
111
  import areasData from '../../libs/util/area';
97
112
  import { CitySelectProps } from './types';
98
-
99
- defineOptions({
100
- name: 'u-city-select'
101
- });
113
+ import { $u } from '../..';
102
114
 
103
115
  /**
104
116
  * u-city-select 城市选择器
@@ -1,5 +1,6 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import type { AlignType, JustifyType } from '../../types/global';
3
+ import { baseProps } from '../common/props';
3
4
 
4
5
  /**
5
6
  * u-col 布局单元格 Props
@@ -13,6 +14,7 @@ import type { AlignType, JustifyType } from '../../types/global';
13
14
  */
14
15
 
15
16
  export const ColProps = {
17
+ ...baseProps,
16
18
  /** 占父容器宽度的多少等分,总分为12份 */
17
19
  span: { type: [Number, String] as PropType<number | string>, default: 12 },
18
20
  /** 指定栅格左侧的间隔数(总12栏) */
@@ -1,16 +1,31 @@
1
1
  <template>
2
- <view class="u-col" :class="['u-col-' + span]" :style="colStyle" @tap="onClick">
2
+ <view
3
+ class="u-col"
4
+ :class="['u-col-' + span, customClass]"
5
+ :style="$u.toStyle(colStyle, customStyle)"
6
+ @tap="onClick"
7
+ >
3
8
  <slot></slot>
4
9
  </view>
5
10
  </template>
6
11
 
12
+ <script lang="ts">
13
+ export default {
14
+ name: 'u-col',
15
+ options: {
16
+ addGlobalClass: true,
17
+ // #ifndef MP-TOUTIAO
18
+ virtualHost: true,
19
+ // #endif
20
+ styleIsolation: 'shared'
21
+ }
22
+ };
23
+ </script>
24
+
7
25
  <script setup lang="ts">
8
- import { computed, inject } from 'vue';
26
+ import { computed } from 'vue';
9
27
  import { ColProps } from './types';
10
-
11
- defineOptions({
12
- name: 'u-col'
13
- });
28
+ import { $u, useChildren } from '../../';
14
29
 
15
30
  /**
16
31
  * col 布局单元格
@@ -26,10 +41,14 @@ const emit = defineEmits<{ (e: 'click'): void }>();
26
41
 
27
42
  const props = defineProps(ColProps);
28
43
 
44
+ const { parentExposed } = useChildren('u-col', 'u-row');
45
+
29
46
  /**
30
47
  * gutter 给col添加间距,左右边距各占一半,从父组件u-row获取
31
48
  */
32
- const gutter = inject('u-row-gutter', 20);
49
+ const gutter = computed(() => {
50
+ return parentExposed?.value?.props?.gutter ?? 20;
51
+ });
33
52
 
34
53
  /**
35
54
  * 计算水平排列方式
@@ -55,7 +74,7 @@ const uAlignItem = computed(() => {
55
74
  * 计算样式对象
56
75
  */
57
76
  const colStyle = computed<any>(() => ({
58
- padding: `0 ${Number(gutter) / 2}rpx`,
77
+ padding: `0 ${Number(gutter.value) / 2}px`,
59
78
  marginLeft: `${(100 / 12) * Number(props.offset)}%`,
60
79
  flex: `0 0 ${(100 / 12) * Number(props.span)}%`,
61
80
  alignItems: uAlignItem.value,
@@ -92,13 +92,17 @@ function onChange(name: string | number) {
92
92
  // 收集当前所有展开的项
93
93
  let currentActiveNames: (string | number)[] = [];
94
94
  if (props.accordion) {
95
- currentActiveNames = activeName.value ? [activeName.value] : [];
95
+ currentActiveNames = activeName.value === 0 || activeName.value ? [activeName.value] : [];
96
96
  } else {
97
- // 对于非手风琴模式,我们不知道所有项的状态,所以这里不处理
97
+ // 对于非手风琴模式,我们不知道所有项的状态
98
98
  currentActiveNames = [];
99
+ children.forEach(child => {
100
+ if (child.getExposed().isShow.value) {
101
+ currentActiveNames.push(child.getExposed().itemName);
102
+ }
103
+ });
99
104
  }
100
-
101
- emit('change', props.accordion ? activeName.value || '' : currentActiveNames);
105
+ currentActiveNames.length > 0 && emit('change', props.accordion ? activeName.value || '' : currentActiveNames);
102
106
  }
103
107
 
104
108
  /**
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <view class="u-collapse-item" :style="`${$u.toStyle(itemStyle)}${$u.toStyle(customStyle)}`" :class="customClass">
2
+ <view class="u-collapse-item" :style="$u.toStyle(itemStyle, customStyle)" :class="customClass">
3
3
  <view
4
4
  :hover-stay-time="200"
5
5
  class="u-collapse-head"
@@ -42,7 +42,7 @@ export default {
42
42
 
43
43
  <script setup lang="ts">
44
44
  import { ref, watch, onMounted, useSlots, getCurrentInstance, nextTick, computed } from 'vue';
45
- import { $u, useChildren, useParentEvents } from '../..';
45
+ import { $u, useChildren } from '../..';
46
46
  import { CollapseItemProps } from './types';
47
47
 
48
48
  /**
@@ -148,11 +148,8 @@ function init() {
148
148
  */
149
149
  function headClick() {
150
150
  if (props.disabled) return;
151
-
152
151
  // 通知父组件状态变化
153
- if (parentExposed.value?.onChange) {
154
- parentExposed.value.onChange(itemName.value);
155
- }
152
+ parentExposed?.value?.onChange(itemName.value);
156
153
  }
157
154
 
158
155
  /**
@@ -176,27 +173,31 @@ function queryRect() {
176
173
  });
177
174
  }
178
175
 
179
- // 使用自动取消监听注册父组件事件
180
- useParentEvents(childId, {
181
- openSingle: (data: any) => {
182
- // 只有目标项展开,其他都关闭
183
- const shouldShow = data.targetName === itemName.value;
184
- setShowState(shouldShow);
185
- },
186
- closeAll: () => {
187
- setShowState(false);
188
- },
189
- setMultiple: (data: any) => {
190
- const shouldShow = data.targetNames.includes(itemName.value);
191
- setShowState(shouldShow);
192
- },
193
- toggleSingle: (data: any) => {
194
- // 只有目标项才切换状态
195
- if (data.targetName === itemName.value) {
196
- setShowState(!isShow.value);
197
- }
176
+ // 单选
177
+ function openSingle(data: any) {
178
+ // 只有目标项展开,其他都关闭
179
+ const shouldShow = data.targetName === itemName.value;
180
+ setShowState(shouldShow);
181
+ }
182
+
183
+ // 关闭所有
184
+ function closeAll() {
185
+ setShowState(false);
186
+ }
187
+
188
+ // 多选
189
+ function setMultiple(data: any) {
190
+ const shouldShow = data.targetNames.includes(itemName.value);
191
+ setShowState(shouldShow);
192
+ }
193
+
194
+ // 切换单个
195
+ function toggleSingle(data: any) {
196
+ // 只有目标项才切换状态
197
+ if (data.targetName === itemName.value) {
198
+ setShowState(!isShow.value);
198
199
  }
199
- });
200
+ }
200
201
 
201
202
  onMounted(() => {
202
203
  // 关键修复:根据 open 属性设置初始状态
@@ -236,7 +237,11 @@ defineExpose({
236
237
  hoverClass,
237
238
  itemName: itemName.value,
238
239
  queryRect,
239
- setShowState
240
+ setShowState,
241
+ openSingle,
242
+ closeAll,
243
+ setMultiple,
244
+ toggleSingle
240
245
  });
241
246
  </script>
242
247
 
@@ -1,10 +1,12 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import type { Direction, PlayState, ScrollDirection, ThemeType } from '../../types/global';
3
+ import { baseProps } from '../common/props';
3
4
 
4
5
  /**
5
6
  * u-column-notice 通告栏 Props
6
7
  */
7
8
  export const ColumnNoticeProps = {
9
+ ...baseProps,
8
10
  /** 显示的内容,数组 */
9
11
  list: { type: Array as PropType<string[]>, default: () => [] },
10
12
  /** 显示的主题,success|error|primary|info|warning */
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <view
3
3
  class="u-notice-bar"
4
- :style="{ background: computeBgColor, padding: props.padding }"
5
- :class="[props.type ? `u-type-${props.type}-light-bg` : '']"
4
+ :style="$u.toStyle({ background: computeBgColor, padding: props.padding }, customStyle)"
5
+ :class="[props.type ? `u-type-${props.type}-light-bg` : '', customClass]"
6
6
  >
7
7
  <view class="u-icon-wrap">
8
8
  <u-icon
@@ -54,11 +54,23 @@
54
54
  </view>
55
55
  </template>
56
56
 
57
+ <script lang="ts">
58
+ export default {
59
+ name: 'u-column-notice',
60
+ options: {
61
+ addGlobalClass: true,
62
+ // #ifndef MP-TOUTIAO
63
+ virtualHost: true,
64
+ // #endif
65
+ styleIsolation: 'shared'
66
+ }
67
+ };
68
+ </script>
69
+
57
70
  <script setup lang="ts">
58
71
  import { computed } from 'vue';
59
72
  import { ColumnNoticeProps } from './types';
60
-
61
- defineOptions({ name: 'u-column-notice' });
73
+ import { $u } from '../../';
62
74
 
63
75
  /**
64
76
  * u-column-notice 通告栏
@@ -1,10 +1,12 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
+ import { baseProps } from '../common/props';
2
3
 
3
4
  /**
4
5
  * u-count-down 倒计时 Props
5
6
  * @description 该组件一般使用于某个活动的截止时间上,通过数字的变化,给用户明确的时间感受,提示用户进行某一个行为操作。
6
7
  */
7
8
  export const CountDownProps = {
9
+ ...baseProps,
8
10
  /** 倒计时的时间,秒为单位 */
9
11
  timestamp: { type: [Number, String] as PropType<number | string>, default: 0 },
10
12
  /** 是否自动开始倒计时 */
@@ -1,11 +1,11 @@
1
1
  <template>
2
- <view class="u-countdown">
2
+ <view class="u-countdown" :class="customClass" :style="$u.toStyle(customStyle)">
3
3
  <view
4
4
  class="u-countdown-item"
5
- :style="[itemStyle]"
5
+ :style="$u.toStyle(itemStyle)"
6
6
  v-if="props.showDays && (props.hideZeroDay || (!props.hideZeroDay && d != '00'))"
7
7
  >
8
- <view class="u-countdown-time" :style="[letterStyle]">
8
+ <view class="u-countdown-time" :style="$u.toStyle(letterStyle)">
9
9
  {{ d }}
10
10
  </view>
11
11
  </view>
@@ -20,7 +20,7 @@
20
20
  >
21
21
  {{ props.separator == 'colon' && props.showHours ? ':' : '天' }}
22
22
  </view>
23
- <view class="u-countdown-item" :style="[itemStyle]" v-if="props.showHours">
23
+ <view class="u-countdown-item" :style="$u.toStyle(itemStyle)" v-if="props.showHours">
24
24
  <view class="u-countdown-time" :style="{ fontSize: props.fontSize + 'rpx', color: props.color }">
25
25
  {{ h }}
26
26
  </view>
@@ -36,7 +36,7 @@
36
36
  >
37
37
  {{ props.separator == 'colon' && props.showMinutes ? ':' : '时' }}
38
38
  </view>
39
- <view class="u-countdown-item" :style="[itemStyle]" v-if="props.showMinutes">
39
+ <view class="u-countdown-item" :style="$u.toStyle(itemStyle)" v-if="props.showMinutes">
40
40
  <view class="u-countdown-time" :style="{ fontSize: props.fontSize + 'rpx', color: props.color }">
41
41
  {{ i }}
42
42
  </view>
@@ -52,7 +52,7 @@
52
52
  >
53
53
  {{ props.separator == 'colon' && props.showSeconds ? ':' : '分' }}
54
54
  </view>
55
- <view class="u-countdown-item" :style="[itemStyle]" v-if="props.showSeconds">
55
+ <view class="u-countdown-item" :style="$u.toStyle(itemStyle)" v-if="props.showSeconds">
56
56
  <view class="u-countdown-time" :style="{ fontSize: props.fontSize + 'rpx', color: props.color }">
57
57
  {{ s }}
58
58
  </view>
@@ -67,11 +67,23 @@
67
67
  </view>
68
68
  </template>
69
69
 
70
+ <script lang="ts">
71
+ export default {
72
+ name: 'u-count-down',
73
+ options: {
74
+ addGlobalClass: true,
75
+ // #ifndef MP-TOUTIAO
76
+ virtualHost: true,
77
+ // #endif
78
+ styleIsolation: 'shared'
79
+ }
80
+ };
81
+ </script>
82
+
70
83
  <script setup lang="ts">
71
84
  import { ref, computed, watch, onMounted } from 'vue';
72
85
  import { CountDownProps } from './types';
73
-
74
- defineOptions({ name: 'u-count-down' });
86
+ import { $u } from '../../';
75
87
 
76
88
  /**
77
89
  * countDown 倒计时
@@ -1,10 +1,12 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
+ import { baseProps } from '../common/props';
2
3
 
3
4
  /**
4
5
  * u-count-to 数字滚动 Props
5
6
  * @description 该组件一般用于需要滚动数字到某一个值的场景,目标要求是一个递增的值。
6
7
  */
7
8
  export const CountToProps = {
9
+ ...baseProps,
8
10
  /** 开始的数值,默认从0增长到某一个数 */
9
11
  startVal: { type: [Number, String] as PropType<number | string>, default: 0 },
10
12
  /** 要滚动的目标数值,必须 */
@@ -1,21 +1,39 @@
1
1
  <template>
2
2
  <view
3
3
  class="u-count-num"
4
- :style="{
5
- fontSize: props.fontSize + 'rpx',
6
- fontWeight: props.bold ? 'bold' : 'normal',
7
- color: props.color
8
- }"
4
+ :class="customClass"
5
+ :style="
6
+ $u.toStyle(
7
+ {
8
+ fontSize: props.fontSize + 'rpx',
9
+ fontWeight: props.bold ? 'bold' : 'normal',
10
+ color: props.color
11
+ },
12
+ customStyle
13
+ )
14
+ "
9
15
  >
10
16
  {{ displayValue }}
11
17
  </view>
12
18
  </template>
13
19
 
20
+ <script lang="ts">
21
+ export default {
22
+ name: 'u-count-to',
23
+ options: {
24
+ addGlobalClass: true,
25
+ // #ifndef MP-TOUTIAO
26
+ virtualHost: true,
27
+ // #endif
28
+ styleIsolation: 'shared'
29
+ }
30
+ };
31
+ </script>
32
+
14
33
  <script setup lang="ts">
15
34
  import { ref, computed, watch, onMounted, onUnmounted } from 'vue';
16
35
  import { CountToProps } from './types';
17
-
18
- defineOptions({ name: 'u-count-to' });
36
+ import { $u } from '../../';
19
37
 
20
38
  /**
21
39
  * countTo 数字滚动