hy-app 0.1.1 → 0.1.2

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 (92) hide show
  1. package/components/hy-address-picker/hy-address-picker.vue +11 -13
  2. package/components/hy-address-picker/props.ts +2 -3
  3. package/components/hy-address-picker/typing.d.ts +1 -2
  4. package/components/hy-avatar/hy-avatar.vue +9 -9
  5. package/components/hy-avatar/props.ts +2 -2
  6. package/components/hy-avatar/typing.d.ts +1 -1
  7. package/components/hy-badge/hy-badge.vue +5 -4
  8. package/components/hy-badge/props.ts +2 -2
  9. package/components/hy-badge/typing.d.ts +2 -2
  10. package/components/hy-button/hy-button.vue +12 -12
  11. package/components/hy-button/props.ts +4 -5
  12. package/components/hy-button/typing.d.ts +3 -3
  13. package/components/hy-cell/hy-cell.vue +55 -20
  14. package/components/hy-cell/props.ts +2 -2
  15. package/components/hy-cell/typing.d.ts +4 -3
  16. package/components/hy-check-button/hy-check-button.vue +13 -7
  17. package/components/hy-check-button/props.ts +3 -3
  18. package/components/hy-checkbox/hy-checkbox.vue +23 -13
  19. package/components/hy-checkbox/props.ts +4 -5
  20. package/components/hy-checkbox/typing.d.ts +3 -6
  21. package/components/hy-datetime-picker/hy-datetime-picker.vue +36 -36
  22. package/components/hy-datetime-picker/props.ts +2 -2
  23. package/components/hy-datetime-picker/typing.d.ts +1 -1
  24. package/components/hy-form/hy-form.vue +6 -6
  25. package/components/hy-form/props.ts +2 -2
  26. package/components/hy-form/typing.d.ts +1 -1
  27. package/components/hy-grid/hy-grid.vue +4 -3
  28. package/components/hy-grid/props.ts +5 -5
  29. package/components/hy-grid/typing.d.ts +2 -2
  30. package/components/hy-icon/hy-icon.vue +8 -6
  31. package/components/hy-icon/props.ts +5 -5
  32. package/components/hy-input/hy-input.vue +9 -10
  33. package/components/hy-input/props.ts +2 -2
  34. package/components/hy-input/typing.d.ts +2 -2
  35. package/components/hy-login/TheUserLogin.vue +2 -2
  36. package/components/hy-number-step/hy-number-step.vue +54 -35
  37. package/components/hy-number-step/props.ts +2 -2
  38. package/components/hy-number-step/typing.d.ts +1 -1
  39. package/components/hy-overlay/hy-overlay.vue +3 -3
  40. package/components/hy-overlay/props.ts +2 -2
  41. package/components/hy-overlay/typing.d.ts +1 -1
  42. package/components/hy-picker/hy-picker.vue +20 -19
  43. package/components/hy-picker/props.ts +3 -2
  44. package/components/hy-picker/typing.d.ts +5 -1
  45. package/components/hy-popup/hy-popup.vue +6 -6
  46. package/components/hy-popup/props.ts +2 -2
  47. package/components/hy-popup/typing.d.ts +1 -1
  48. package/components/hy-price/hy-price.vue +4 -4
  49. package/components/hy-price/props.ts +2 -2
  50. package/components/hy-price/typing.d.ts +1 -1
  51. package/components/hy-radio/hy-radio.vue +26 -13
  52. package/components/hy-radio/props.ts +4 -4
  53. package/components/hy-radio/typing.d.ts +2 -1
  54. package/components/hy-rate/hy-rate.vue +32 -20
  55. package/components/hy-rate/props.ts +4 -3
  56. package/components/hy-rate/typing.d.ts +1 -1
  57. package/components/hy-search/hy-search.vue +11 -11
  58. package/components/hy-search/props.ts +2 -2
  59. package/components/hy-search/typing.d.ts +1 -2
  60. package/components/hy-slider/hy-slider.vue +32 -31
  61. package/components/hy-slider/props.ts +2 -2
  62. package/components/hy-subsection/hy-subsection.vue +46 -17
  63. package/components/hy-subsection/props.ts +6 -3
  64. package/components/hy-subsection/typing.d.ts +11 -8
  65. package/components/hy-swiper/hy-swiper.vue +44 -11
  66. package/components/hy-swiper/props.ts +3 -3
  67. package/components/hy-swiper/typing.d.ts +7 -4
  68. package/components/hy-switch/hy-switch.vue +11 -4
  69. package/components/hy-switch/props.ts +2 -2
  70. package/components/hy-tag/hy-tag.vue +14 -16
  71. package/components/hy-tag/props.ts +2 -2
  72. package/components/hy-tag/typing.d.ts +2 -2
  73. package/components/hy-textarea/hy-textarea.vue +12 -5
  74. package/components/hy-textarea/props.ts +2 -2
  75. package/components/hy-textarea/typing.d.ts +1 -1
  76. package/components/hy-transition/hy-transition.vue +13 -6
  77. package/components/hy-transition/props.ts +2 -2
  78. package/components/hy-transition/typing.d.ts +1 -1
  79. package/index.scss +1 -0
  80. package/libs/css/common.scss +4 -0
  81. package/libs/css/download.zip +0 -0
  82. package/libs/css/iconfont.css +4 -4
  83. package/libs/css/iconfont.ttf +0 -0
  84. package/libs/css/iconfont.woff +0 -0
  85. package/libs/css/iconfont.woff2 +0 -0
  86. package/package.json +4 -4
  87. package/theme.scss +3 -3
  88. package/typing/index.ts +0 -1
  89. package/typing/modules/common.d.ts +50 -0
  90. package/typing/modules/form.ts +3 -3
  91. package/utils/utils.ts +22 -13
  92. package/typing/modules/img.ts +0 -15
@@ -8,7 +8,7 @@
8
8
  <text
9
9
  class="hy-price__text"
10
10
  :style="[
11
- { 'font-size': `${Number(fontSize) + Number(fontSize) * 0.8}rpx` }
11
+ { 'font-size': `${Number(fontSize) + Number(fontSize) * 0.8}rpx` },
12
12
  ]"
13
13
  >{{ priceOne[0] }}
14
14
  </text>
@@ -19,9 +19,9 @@
19
19
  </template>
20
20
 
21
21
  <script setup lang="ts">
22
- import { computed, CSSProperties, toRefs } from "vue";
22
+ import { computed, type CSSProperties, toRefs } from "vue";
23
23
  import defaultProps from "./props";
24
- import IProps from "./typing";
24
+ import type IProps from "./typing";
25
25
  import { addUnit } from "../../utils";
26
26
 
27
27
  const props = withDefaults(defineProps<IProps>(), defaultProps);
@@ -36,7 +36,7 @@ const priceStyle = computed<CSSProperties>(() => {
36
36
  color: textColor.value,
37
37
  fontWeight: weight.value,
38
38
  fontStyle: slant.value ? "oblique" : "",
39
- fontSize: addUnit(fontSize.value)
39
+ fontSize: addUnit(fontSize.value),
40
40
  };
41
41
 
42
42
  return Object.assign(style, customStyle);
@@ -1,4 +1,4 @@
1
- import IProps from "./typing";
1
+ import type IProps from "./typing";
2
2
 
3
3
  const defaultProps: IProps = {
4
4
  text: "0.00",
@@ -7,7 +7,7 @@ const defaultProps: IProps = {
7
7
  textColor: "#FE3232",
8
8
  fontSize: 22,
9
9
  weight: 500,
10
- slant: false
10
+ slant: false,
11
11
  };
12
12
 
13
13
  export default defaultProps;
@@ -1,4 +1,4 @@
1
- import { CSSProperties } from "vue";
1
+ import type { CSSProperties } from "vue";
2
2
 
3
3
  export default interface IProps {
4
4
  /**
@@ -7,7 +7,7 @@
7
7
  :style="radioStyle"
8
8
  :class="[
9
9
  `hy-radio-label--${iconPlacement}`,
10
- borderBottom && placement === 'column' && 'hy-border-bottom'
10
+ borderBottom && placement === 'column' && 'hy-border-bottom',
11
11
  ]"
12
12
  >
13
13
  <view
@@ -19,12 +19,12 @@
19
19
  <slot
20
20
  name="icon"
21
21
  :iconColor="iconColor"
22
- :iconSize="addUnit(iconSize)"
22
+ :iconSize="addUnit(sizeType[size] ?? iconSize)"
23
23
  >
24
24
  <HyIcon
25
25
  class="hy-radio__icon-wrap__icon"
26
26
  :name="IconConfig.CHECK_MASK"
27
- :size="addUnit(iconSize)"
27
+ :size="addUnit(sizeType[size] ?? iconSize)"
28
28
  :color="iconColorCom(item.checked)"
29
29
  />
30
30
  </slot>
@@ -38,7 +38,7 @@
38
38
  class="hy-radio__text"
39
39
  :style="{
40
40
  color: labelColor,
41
- fontSize: labelSize
41
+ fontSize: addUnit(sizeType[size] ?? labelSize),
42
42
  }"
43
43
  >{{ item[fieldNames.label] }}</text
44
44
  >
@@ -50,10 +50,17 @@
50
50
  </template>
51
51
 
52
52
  <script setup lang="ts">
53
- import IProps from "./typing";
54
- import { CheckboxColumnsVo } from "../hy-check-button/typing";
53
+ import type IProps from "./typing";
54
+ import type { CheckboxColumnsVo } from "../hy-check-button/typing";
55
55
  import defaultProps from "./props";
56
- import { computed, CSSProperties, ref, toRefs, watch } from "vue";
56
+ import {
57
+ computed,
58
+ type CSSProperties,
59
+ reactive,
60
+ ref,
61
+ toRefs,
62
+ watch,
63
+ } from "vue";
57
64
  import { addUnit, bem, error } from "../../utils";
58
65
  import { IconConfig } from "../../config";
59
66
 
@@ -73,21 +80,27 @@ const {
73
80
  customStyle,
74
81
  borderBottom,
75
82
  placement,
76
- iconColor
83
+ iconColor,
77
84
  } = toRefs(props);
78
85
  const emit = defineEmits(["change", "update:modelValue"]);
79
86
 
80
87
  const columns_1 = ref();
88
+ const sizeType: AnyObject = reactive({
89
+ small: 14,
90
+ medium: 18,
91
+ large: 22,
92
+ });
81
93
 
82
94
  watch(
83
95
  () => modelValue.value,
84
96
  (newValue) => {
85
97
  columns_1.value = columns.value.map((item: any) => {
86
- item[fieldNames.value.checked] = newValue == item[fieldNames.value.value];
98
+ item[fieldNames.value.checked] =
99
+ newValue === item[fieldNames.value.value];
87
100
  return item;
88
101
  });
89
102
  },
90
- { immediate: true }
103
+ { immediate: true },
91
104
  );
92
105
 
93
106
  const isDisabled = (disabledVal?: boolean): boolean =>
@@ -116,7 +129,7 @@ const radioStyle = computed(() => {
116
129
  const style: CSSProperties = {};
117
130
  if (borderBottom.value && placement.value === "row") {
118
131
  error(
119
- "检测到您将borderBottom设置为true,需要同时将u-checkbox-group的placement设置为column才有效"
132
+ "检测到您将borderBottom设置为true,需要同时将u-checkbox-group的placement设置为column才有效",
120
133
  );
121
134
  }
122
135
  // 当父组件设置了显示下边框并且排列形式为纵向时,给内容和边框之间加上一定间隔
@@ -162,8 +175,8 @@ const iconWrapStyle = computed(() => {
162
175
  temp[fieldNames.value.checked] && !isDisabled(temp?.disabled)
163
176
  ? activeColor.value
164
177
  : inactiveColor.value;
165
- style.width = addUnit(size.value);
166
- style.height = addUnit(size.value);
178
+ style.width = addUnit(sizeType[size.value] ?? size.value);
179
+ style.height = addUnit(sizeType[size.value] ?? size.value);
167
180
  return style;
168
181
  };
169
182
  });
@@ -1,4 +1,4 @@
1
- import IProps from "./typing";
1
+ import type IProps from "./typing";
2
2
  import { ColorConfig } from "../../config";
3
3
 
4
4
  const defaultProps: IProps = {
@@ -7,10 +7,10 @@ const defaultProps: IProps = {
7
7
  fieldNames: {
8
8
  label: "label",
9
9
  value: "value",
10
- checked: "checked"
10
+ checked: "checked",
11
11
  },
12
12
  shape: "circle",
13
- size: 20,
13
+ size: "medium",
14
14
  disabled: false,
15
15
  activeColor: ColorConfig.primary,
16
16
  inactiveColor: "#c8c9cc",
@@ -22,7 +22,7 @@ const defaultProps: IProps = {
22
22
  labelSize: "",
23
23
  labelColor: "",
24
24
  labelDisabled: "",
25
- placement: "row"
25
+ placement: "row",
26
26
  };
27
27
 
28
28
  export default defaultProps;
@@ -1,5 +1,6 @@
1
1
  import type { CSSProperties } from "vue";
2
2
  import { CheckboxColumnsVo, IFieldNames } from "../hy-check-button/typing";
3
+ import { HyApp } from "@/package/typing/modules/common";
3
4
 
4
5
  export default interface IProps {
5
6
  /**
@@ -25,7 +26,7 @@ export default interface IProps {
25
26
  /**
26
27
  * @description 整体的大小
27
28
  * */
28
- size?: string | number;
29
+ size?: HyApp.SizeType | string | number;
29
30
  /**
30
31
  * @description 是否默认选中
31
32
  * */
@@ -22,11 +22,11 @@
22
22
  disabled
23
23
  ? '#c8c9cc'
24
24
  : Math.floor(activeIndex) > index
25
- ? activeColor
26
- : inactiveColor
25
+ ? activeColor
26
+ : inactiveColor
27
27
  "
28
28
  :custom-style="{
29
- padding: `0 ${addUnit(gutter / 2)}`
29
+ padding: `0 ${addUnit(gutter / 2)}`,
30
30
  }"
31
31
  :size="size"
32
32
  ></HyIcon>
@@ -37,8 +37,8 @@
37
37
  class="hy-rate__content__item__icon-wrap hy-rate__content__item__icon-wrap--half"
38
38
  :style="[
39
39
  {
40
- width: addUnit(rateWidth / 2)
41
- }
40
+ width: addUnit(rateWidth / 2),
41
+ },
42
42
  ]"
43
43
  ref="hy-rate__content__item__icon-wrap"
44
44
  >
@@ -48,11 +48,11 @@
48
48
  disabled
49
49
  ? '#c8c9cc'
50
50
  : Math.ceil(activeIndex) > index
51
- ? activeColor
52
- : inactiveColor
51
+ ? activeColor
52
+ : inactiveColor
53
53
  "
54
54
  :custom-style="{
55
- padding: `0 ${addUnit(gutter / 2)}`
55
+ padding: `0 ${addUnit(gutter / 2)}`,
56
56
  }"
57
57
  :size="size"
58
58
  ></HyIcon>
@@ -64,8 +64,8 @@
64
64
 
65
65
  <script setup lang="ts">
66
66
  import { addUnit, getRect, guid, range, sleep } from "../../utils";
67
- import { ref, watch, toRefs, onMounted, nextTick } from "vue";
68
- import IProps from "./typing";
67
+ import { ref, watch, toRefs, onMounted, getCurrentInstance } from "vue";
68
+ import type IProps from "./typing";
69
69
  import defaultProps from "./props";
70
70
 
71
71
  // 组件
@@ -79,7 +79,7 @@ const {
79
79
  count,
80
80
  disabled,
81
81
  readonly,
82
- allowHalf
82
+ allowHalf,
83
83
  } = toRefs(props);
84
84
  const emit = defineEmits(["update:modelValue", "change"]);
85
85
 
@@ -96,40 +96,52 @@ watch(
96
96
  () => modelValue.value,
97
97
  (newValue) => {
98
98
  activeIndex.value = newValue;
99
- }
99
+ },
100
100
  );
101
101
  watch(
102
102
  () => activeIndex.value,
103
103
  (newVal) => {
104
104
  emitEvent();
105
- }
105
+ },
106
106
  );
107
+ const instance = getCurrentInstance();
107
108
 
108
109
  onMounted(() => {
109
110
  init();
110
111
  });
111
112
 
112
113
  const init = () => {
113
- sleep(200).then(() => {
114
- getRateItemRect();
115
- getRateIconWrapRect();
114
+ sleep(300).then(async () => {
115
+ await getRateItemRect();
116
+ await getRateIconWrapRect();
116
117
  });
117
118
  };
118
119
 
119
- // 获取评分组件盒子的布局信息
120
+ /**
121
+ * @description 获取评分组件盒子的布局信息
122
+ * */
120
123
  const getRateItemRect = async () => {
121
124
  await sleep();
122
125
  // #ifndef APP-NVUE
123
- const res: UniApp.NodeInfo = (await getRect(`#${elId}`)) as UniApp.NodeInfo;
126
+ const res: UniApp.NodeInfo = (await getRect(
127
+ `#${elId}`,
128
+ false,
129
+ instance,
130
+ )) as UniApp.NodeInfo;
124
131
  rateBoxLeft.value = res.left || 0;
125
132
  // #endif
126
133
  };
127
- // 获取单个星星的尺寸
134
+
135
+ /**
136
+ * @description 获取单个星星的尺寸
137
+ * */
128
138
  const getRateIconWrapRect = async () => {
129
139
  // uView封装的获取节点的方法,详见文档
130
140
  // #ifndef APP-NVUE
131
141
  const res: UniApp.NodeInfo = (await getRect(
132
- `.${elClass}`
142
+ `.${elClass}`,
143
+ false,
144
+ instance,
133
145
  )) as UniApp.NodeInfo;
134
146
  rateWidth.value = res.width || 0;
135
147
  // #endif
@@ -1,18 +1,19 @@
1
1
  import { ColorConfig, IconConfig } from "../../config";
2
+ import type IProps from "./typing";
2
3
 
3
- const defaultProps = {
4
+ const defaultProps: IProps = {
4
5
  modelValue: 1,
5
6
  count: 5,
6
7
  disabled: false,
7
8
  readonly: false,
8
9
  size: 18,
9
10
  inactiveColor: "#b2b2b2",
10
- activeColor: ColorConfig.primary,
11
+ activeColor: "#FFF00D",
11
12
  gutter: 4,
12
13
  minCount: 1,
13
14
  allowHalf: false,
14
15
  activeIcon: IconConfig.STAR_FILL,
15
16
  inactiveIcon: IconConfig.STAR,
16
- touchable: true
17
+ touchable: true,
17
18
  };
18
19
  export default defaultProps;
@@ -1,4 +1,4 @@
1
- import { CSSProperties } from "vue";
1
+ import type { CSSProperties } from "vue";
2
2
 
3
3
  export default interface IProps {
4
4
  /**
@@ -4,9 +4,9 @@
4
4
  @tap="clickHandler"
5
5
  :style="[
6
6
  {
7
- margin: margin
7
+ margin: margin,
8
8
  },
9
- customStyle
9
+ customStyle,
10
10
  ]"
11
11
  >
12
12
  <view
@@ -14,7 +14,7 @@
14
14
  :style="{
15
15
  backgroundColor: bgColor,
16
16
  borderRadius: shape == 'circle' ? '100px' : '4px',
17
- borderColor: borderColor
17
+ borderColor: borderColor,
18
18
  }"
19
19
  >
20
20
  <template v-if="$slots.label || label !== null">
@@ -53,9 +53,9 @@
53
53
  textAlign: inputAlign,
54
54
  color: color,
55
55
  backgroundColor: bgColor,
56
- height: addUnit(height)
56
+ height: addUnit(height),
57
57
  },
58
- inputStyle
58
+ inputStyle,
59
59
  ]"
60
60
  />
61
61
  <view
@@ -68,7 +68,7 @@
68
68
  size="11"
69
69
  color="#ffffff"
70
70
  :customStyle="{
71
- lineHeight: '12px'
71
+ lineHeight: '12px',
72
72
  }"
73
73
  ></HyIcon>
74
74
  </view>
@@ -86,8 +86,8 @@
86
86
  <script setup lang="ts">
87
87
  import { computed, nextTick, toRefs, ref, watch } from "vue";
88
88
  import defaultProps from "./props";
89
- import IProps from "./typing";
90
- import { addUnit, sleep } from "../../utils";
89
+ import type IProps from "./typing";
90
+ import { sleep, addUnit } from "../../utils";
91
91
  import { IconConfig } from "../../config";
92
92
  import HyIcon from "../hy-icon/hy-icon.vue";
93
93
 
@@ -103,7 +103,7 @@ const emit = defineEmits([
103
103
  "confirm",
104
104
  "change",
105
105
  "focus",
106
- "blur"
106
+ "blur",
107
107
  ]);
108
108
 
109
109
  const keyword = ref<string>("");
@@ -118,7 +118,7 @@ watch(
118
118
  (newValue: string) => {
119
119
  emit("update:modelValue", newValue);
120
120
  emit("change", newValue);
121
- }
121
+ },
122
122
  );
123
123
 
124
124
  watch(
@@ -126,7 +126,7 @@ watch(
126
126
  (newValue: string) => {
127
127
  keyword.value = newValue;
128
128
  },
129
- { immediate: true }
129
+ { immediate: true },
130
130
  );
131
131
 
132
132
  const showActionBtn = computed<boolean>(() => {
@@ -1,4 +1,4 @@
1
- import IProps from "./typing";
1
+ import type IProps from "./typing";
2
2
 
3
3
  const defaultProps: IProps = {
4
4
  modelValue: "",
@@ -23,7 +23,7 @@ const defaultProps: IProps = {
23
23
  height: 32,
24
24
  label: null,
25
25
  adjustPosition: true,
26
- autoBlur: true
26
+ autoBlur: true,
27
27
  };
28
28
 
29
29
  export default defaultProps;
@@ -1,5 +1,4 @@
1
- import { CSSProperties } from "vue";
2
- import { b } from "vite/dist/node/types.d-aGj9QkWt";
1
+ import type { CSSProperties } from "vue";
3
2
 
4
3
  export default interface IProps {
5
4
  /**
@@ -14,7 +14,7 @@
14
14
  height:
15
15
  isRange && showValue
16
16
  ? addUnit(Number(blockSize) + 24)
17
- : addUnit(blockSize)
17
+ : addUnit(blockSize),
18
18
  }"
19
19
  >
20
20
  <view
@@ -23,8 +23,8 @@
23
23
  :style="[
24
24
  {
25
25
  height: height,
26
- backgroundColor: inactiveColor
27
- }
26
+ backgroundColor: inactiveColor,
27
+ },
28
28
  ]"
29
29
  >
30
30
  </view>
@@ -36,8 +36,8 @@
36
36
  {
37
37
  height: height,
38
38
  marginTop: '-' + height,
39
- backgroundColor: activeColor
40
- }
39
+ backgroundColor: activeColor,
40
+ },
41
41
  ]"
42
42
  >
43
43
  </view>
@@ -49,8 +49,8 @@
49
49
  {
50
50
  height: height,
51
51
  marginTop: '-' + height,
52
- backgroundColor: inactiveColor
53
- }
52
+ backgroundColor: inactiveColor,
53
+ },
54
54
  ]"
55
55
  >
56
56
  </view>
@@ -58,7 +58,7 @@
58
58
  v-if="isRange && showValue"
59
59
  class="hy-slider__show-range-value"
60
60
  :style="{
61
- left: blockLeft(barStyle?.width, blockSize)
61
+ left: blockLeft(barStyle?.width, blockSize),
62
62
  }"
63
63
  >
64
64
  {{ rangeValue[0] }}
@@ -67,7 +67,7 @@
67
67
  v-if="isRange && showValue"
68
68
  class="hy-slider__show-range-value"
69
69
  :style="{
70
- left: blockLeft(barStyle?.width, blockSize)
70
+ left: blockLeft(barStyle?.width, blockSize),
71
71
  }"
72
72
  >
73
73
  {{ rangeValue[1] }}
@@ -80,7 +80,7 @@
80
80
  @touchend="onTouchEnd($event, 0)"
81
81
  @touchcancel="onTouchEnd($event, 0)"
82
82
  :style="{
83
- left: blockLeft(barStyle?.width, blockSize)
83
+ left: blockLeft(barStyle?.width, blockSize),
84
84
  }"
85
85
  >
86
86
  <slot name="min" v-if="$slots.min || $slots.$min" />
@@ -92,8 +92,8 @@
92
92
  {
93
93
  height: addUnit(blockSize),
94
94
  width: addUnit(blockSize),
95
- backgroundColor: blockColor
96
- }
95
+ backgroundColor: blockColor,
96
+ },
97
97
  ]"
98
98
  ></view>
99
99
  </view>
@@ -105,7 +105,7 @@
105
105
  @touchend="onTouchEnd"
106
106
  @touchcancel="onTouchEnd"
107
107
  :style="{
108
- left: blockLeft(barStyle?.width, blockSize)
108
+ left: blockLeft(barStyle?.width, blockSize),
109
109
  }"
110
110
  >
111
111
  <slot name="max" v-if="isRange && ($slots.max || $slots.$max)" />
@@ -118,8 +118,8 @@
118
118
  {
119
119
  height: addUnit(blockSize),
120
120
  width: addUnit(blockSize),
121
- backgroundColor: blockColor
122
- }
121
+ backgroundColor: blockColor,
122
+ },
123
123
  ]"
124
124
  ></view>
125
125
  </view>
@@ -154,12 +154,11 @@ import {
154
154
  onMounted,
155
155
  ref,
156
156
  toRefs,
157
- watch
157
+ watch,
158
158
  } from "vue";
159
159
  import defaultProps from "./props";
160
- import IProps from "./typing";
160
+ import type IProps from "./typing";
161
161
  import { addUnit, error, getRect, sleep } from "../../utils";
162
- import NodeInfo = UniNamespace.NodeInfo;
163
162
 
164
163
  const props = withDefaults(defineProps<IProps>(), defaultProps);
165
164
  const { modelValue, rangeValue, useNative, isRange, disabled, step, min, max } =
@@ -174,20 +173,20 @@ const startValue0 = ref(0);
174
173
  const startValue = ref(0);
175
174
  const barStyle0 = ref<CSSProperties>();
176
175
  const barStyle = ref<CSSProperties>();
177
- const sliderRect = ref<NodeInfo>({
176
+ const sliderRect = ref<UniNamespace.NodeInfo>({
178
177
  left: 0,
179
- width: 0
178
+ width: 0,
180
179
  });
181
180
 
182
181
  const blockLeft = computed(() => {
183
182
  return (
184
183
  slideWidth: string | number | undefined,
185
- blockWidth: string | number
184
+ blockWidth: string | number,
186
185
  ): string => {
187
186
  if (slideWidth) {
188
187
  return addUnit(
189
188
  parseInt(slideWidth.toString().replace("px", "")) +
190
- Number(blockWidth) / 2
189
+ Number(blockWidth) / 2,
191
190
  );
192
191
  }
193
192
  return "0px";
@@ -199,7 +198,7 @@ watch(
199
198
  (newValue) => {
200
199
  // 只有在非滑动状态时,才可以通过value更新滑块值,这里监听,是为了让用户触发
201
200
  if (status.value === "end") updateValue(newValue, false);
202
- }
201
+ },
203
202
  );
204
203
 
205
204
  watch(
@@ -210,14 +209,16 @@ watch(
210
209
  updateValue(newValue[1], false, 1);
211
210
  }
212
211
  },
213
- { deep: true }
212
+ { deep: true },
214
213
  );
215
214
 
216
215
  onMounted(async () => {
217
216
  // 获取滑块条的尺寸信息
218
217
  if (!useNative.value) {
219
218
  // #ifndef APP-NVUE
220
- sliderRect.value = (await getRect(".hy-slider__base")) as NodeInfo;
219
+ sliderRect.value = (await getRect(
220
+ ".hy-slider__base",
221
+ )) as UniNamespace.NodeInfo;
221
222
  // console.log('sliderRect', sliderRect.value)
222
223
  if (sliderRect.value.width == 0) {
223
224
  error("如在弹窗等元素中使用,请使用v-if来显示滑块,否则无法计算长度。");
@@ -359,10 +360,10 @@ const updateValue = (value: number, drag: boolean, index: number = 1) => {
359
360
  let width = Math.min(
360
361
  ((valueFormat - min.value) / (max.value - min.value)) *
361
362
  sliderRect.value.width!,
362
- sliderRect.value.width!
363
+ sliderRect.value.width!,
363
364
  );
364
365
  let barStyle_1: CSSProperties = {
365
- width: width + "px"
366
+ width: width + "px",
366
367
  };
367
368
  // 移动期间无需过渡动画
368
369
  if (drag == true) {
@@ -404,8 +405,8 @@ const format = (value: number, index = 1): number => {
404
405
  Math.round(
405
406
  Math.max(
406
407
  min.value,
407
- Math.min(value, rangeValue.value[1] - step.value, max.value)
408
- ) / step.value
408
+ Math.min(value, rangeValue.value[1] - step.value, max.value),
409
+ ) / step.value,
409
410
  ) * step.value
410
411
  );
411
412
  case 1:
@@ -414,8 +415,8 @@ const format = (value: number, index = 1): number => {
414
415
  Math.max(
415
416
  min.value,
416
417
  rangeValue.value[0] + step.value,
417
- Math.min(value, max.value)
418
- ) / step.value
418
+ Math.min(value, max.value),
419
+ ) / step.value,
419
420
  ) * step.value
420
421
  );
421
422
  default:
@@ -1,4 +1,4 @@
1
- import IProps from "./typing";
1
+ import type IProps from "./typing";
2
2
  import { ColorConfig } from "../../config";
3
3
 
4
4
  const defaultProps: IProps = {
@@ -15,7 +15,7 @@ const defaultProps: IProps = {
15
15
  useNative: false,
16
16
  height: "2px",
17
17
  rangeValue: [0, 0],
18
- isRange: false
18
+ isRange: false,
19
19
  };
20
20
 
21
21
  export default defaultProps;