yh-mobile-components 1.3.0 → 1.3.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ - v1.3.2 yhm-input 修复 input 框没有 focus方法的问题
2
+ - v1.3.1 yhm-select 修复值域下拉选项不匹配导致报错的问题
package/form/yhmInput.vue CHANGED
@@ -7,6 +7,7 @@
7
7
  @keydown="keydownHandler"
8
8
  :type="inputType"
9
9
  :error="error"
10
+ ref="fieldRef"
10
11
  :error-message="errorMessage">
11
12
  <template
12
13
  #right-icon
@@ -28,7 +29,7 @@
28
29
  </van-field>
29
30
  </template>
30
31
  <script setup lang="ts">
31
- import { computed } from "vue";
32
+ import { computed, ref } from "vue";
32
33
  const props = withDefaults(
33
34
  defineProps<{
34
35
  type?: string;
@@ -71,6 +72,16 @@ function keydownHandler(e: KeyboardEvent) {
71
72
  }
72
73
  }
73
74
  }
75
+
76
+ const fieldRef = ref();
77
+ function focus() {
78
+ fieldRef.value?.focus();
79
+ }
80
+
81
+ function blur() {
82
+ fieldRef.value?.blur();
83
+ }
84
+ defineExpose({ fieldRef, focus, blur });
74
85
  </script>
75
86
  <style lang="scss">
76
87
  .yhm-input-container {
@@ -41,7 +41,8 @@ const emits = defineEmits<{
41
41
 
42
42
  const valueString = computed(() => {
43
43
  if (props.modelValue) {
44
- return props.optionData.filter((item) => item.value === props.modelValue)[0].text;
44
+ let option = props.optionData.filter((item) => item.value === props.modelValue)[0];
45
+ return option ? option.text : props.modelValue;
45
46
  } else {
46
47
  return props.palceholder || "请选择";
47
48
  }
@@ -25,8 +25,6 @@
25
25
  </van-field>
26
26
  </template>
27
27
  <script setup lang="ts">
28
- import { computed } from "vue";
29
-
30
28
  const props = withDefaults(
31
29
  defineProps<{
32
30
  error?: boolean;
@@ -16,7 +16,7 @@
16
16
  </section>
17
17
  </template>
18
18
  <script setup lang="ts">
19
- import { computed, ref } from "vue";
19
+ import { computed } from "vue";
20
20
  const props = withDefaults(
21
21
  defineProps<{
22
22
  span: number;
@@ -24,13 +24,23 @@ const props = withDefaults(
24
24
  value?: string;
25
25
  description?: string;
26
26
  regularValue?: boolean;
27
+ fontSize?: number;
28
+ align?: "left" | "center" | "right";
29
+ descAlign?: "left" | "center" | "right";
27
30
  status?: "primary" | "success" | "danger" | "warning" | "cyan" | "purple" | "yellow" | "pink";
28
31
  }>(),
29
32
  {
30
33
  span: 24,
34
+ fontSize: 14,
35
+ align: "right",
36
+ descAlign: "left",
31
37
  }
32
38
  );
33
39
 
40
+ const fontSize = computed(() => {
41
+ return `${props.fontSize}px`;
42
+ });
43
+
34
44
  const widthCount = computed(() => {
35
45
  return 24 / props.span;
36
46
  });
@@ -38,22 +48,21 @@ const widthCount = computed(() => {
38
48
  <style lang="scss">
39
49
  .yhm-info-item-container {
40
50
  width: calc((100% - (8px * v-bind(widthCount))) / v-bind(widthCount));
41
- font-size: var(--van-font-size-md);
51
+ font-size: v-bind(fontSize);
42
52
  padding: 4px 0;
43
53
  margin-right: 8px;
44
54
  .yhm-info-item {
45
55
  display: flex;
46
56
  padding: 4px 0;
47
- line-height: 18px;
57
+ line-height: 1.3em;
48
58
  .yhm-info-item-value {
49
59
  flex: 1;
50
- text-align: right;
51
60
  color: var(--van-text-color-2);
61
+ text-align: v-bind("$props.align");
62
+ padding-left: 5px;
52
63
  }
53
64
  &.regular-value {
54
65
  .yhm-info-item-value {
55
- flex: 1;
56
- text-align: right;
57
66
  color: var(--van-text-color);
58
67
  }
59
68
  }
@@ -61,7 +70,8 @@ const widthCount = computed(() => {
61
70
  .yhm-info-description {
62
71
  color: var(--van-text-color-2);
63
72
  padding: 2px 0;
64
- line-height: 16px;
73
+ line-height: 1.3em;
74
+ text-align: v-bind("$props.descAlign");
65
75
  }
66
76
  &.primary {
67
77
  .yhm-info-item {
package/info/yhmList.vue CHANGED
@@ -33,13 +33,17 @@
33
33
  finished-text="没有更多了"
34
34
  ref="scrollContent"
35
35
  @load="getList">
36
- <template v-for="(row, index) in list">
36
+ <template v-for="row in list">
37
37
  <yhm-info has-top>
38
38
  <template v-for="item in listConfig?.items">
39
39
  <yhm-info-item
40
40
  v-if="!item.show || (item.show && item.show(row))"
41
41
  :label="item.label"
42
+ regular-value
42
43
  :span="item.span"
44
+ :align="item.align || align"
45
+ :desc-align="item.descAlign || descAlign"
46
+ :font-size="item.fontSize || fontSize"
43
47
  :status="item.status && item.status(row)"
44
48
  :description="row[item.description] || item.description"
45
49
  :value="row[item.value] || item.value">
@@ -50,7 +54,9 @@
50
54
  </yhm-info-item>
51
55
  </template>
52
56
  </yhm-info>
53
- <yhm-info class="yhm-list-item-actions">
57
+ <yhm-info
58
+ class="yhm-list-item-actions"
59
+ v-if="listConfig.btns && listConfig.btns.length > 0">
54
60
  <template v-for="btn in listConfig.btns">
55
61
  <div
56
62
  v-if="!btn.show || (btn.show && btn.show(row))"
@@ -69,9 +75,6 @@
69
75
  import type { ListConfig, ParamConfig } from "../types";
70
76
  import type { ListInstance } from "vant";
71
77
  import { ref, reactive, computed, onMounted, onActivated } from "vue";
72
- import { useRouter } from "vue-router";
73
-
74
- const router = useRouter();
75
78
 
76
79
  const props = withDefaults(
77
80
  defineProps<{
@@ -80,6 +83,9 @@ const props = withDefaults(
80
83
  /** 关键字筛选提示语 */
81
84
  searchPlaceholder?: string;
82
85
  paramType?: "dropdown" | "tabs";
86
+ align?: "left" | "center" | "right";
87
+ descAlign?: "left" | "center" | "right";
88
+ fontSize?: number;
83
89
  /** 下拉筛选条件配置 */
84
90
  paramConfig?: ParamConfig[];
85
91
  /** 列表项目筛选 */
@@ -97,6 +103,8 @@ const props = withDefaults(
97
103
  {
98
104
  hasSearch: false,
99
105
  searchPlaceholder: "输入关键词搜索",
106
+ align: "right",
107
+ descAlign: "left",
100
108
  }
101
109
  );
102
110
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yh-mobile-components",
3
- "version": "1.3.0",
3
+ "version": "1.3.3",
4
4
  "description": "移动端组件封装及配置化需求",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/types.ts CHANGED
@@ -7,7 +7,7 @@ export type SizeType = "mini" | "medium" | "lager";
7
7
  /** 下拉参数配置 */
8
8
  export interface ParamConfig {
9
9
  optionData?: vanOption[];
10
- type: "tabs" | "dropdown";
10
+ type?: "tabs" | "dropdown";
11
11
  value: string;
12
12
  defaultValue: any;
13
13
  }
@@ -39,8 +39,11 @@ export interface ListItem<T> {
39
39
  label: string;
40
40
  /** 字段值或者键,显示在右上方 */
41
41
  value: keyof T;
42
+ align?: "left" | "center" | "right";
42
43
  /** 字段描述或者键,显示在下方 */
43
- description: keyof T;
44
+ description?: keyof T;
45
+ descAlign?: "left" | "center" | "right";
46
+ fontSize?: number;
44
47
  /** 自定义插槽,用来渲染自定义元素 */
45
48
  slot?: string;
46
49
  /** 值的样式,自定义不同的颜色
@@ -65,6 +68,9 @@ export interface ListConfigObject<T> {
65
68
  hasSearch: boolean;
66
69
  searchPlaceholder: string;
67
70
  paramType?: "dropdown" | "tabs";
71
+ align?: "left" | "center" | "right";
72
+ descAlign?: "left" | "center" | "right";
73
+ fontSize: number;
68
74
  paramConfig: ParamConfig[];
69
75
  listConfig: ListConfig<T>;
70
76
  getData: (pageIndex, pageSie, params, keyword) => Promise<{ data: any[]; total: number }>;