yh-mobile-components 1.0.5 → 1.0.7

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.
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <section></section>
3
+ </template>
4
+ <script setup lang="ts"></script>
5
+ <style lang="scss"></style>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <section></section>
3
+ </template>
4
+ <script setup lang="ts"></script>
5
+ <style lang="scss"></style>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <section></section>
3
+ </template>
4
+ <script setup lang="ts"></script>
5
+ <style lang="scss"></style>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <section></section>
3
+ </template>
4
+ <script setup lang="ts"></script>
5
+ <style lang="scss"></style>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <section></section>
3
+ </template>
4
+ <script setup lang="ts"></script>
5
+ <style lang="scss"></style>
package/index.ts CHANGED
@@ -3,6 +3,7 @@ import yhmDropdownItem from "./info/yhmDropdownItem.vue";
3
3
  import yhmTabs from "./info/yhmTabs.vue";
4
4
  import yhmInfo from "./info/yhmInfo.vue";
5
5
  import yhmInfoItem from "./info/yhmInfoItem.vue";
6
+ import yhmTable from "./info/yhmTable.vue";
6
7
  import yhmForm from "./form/yhm-form.vue";
7
8
  import yhmDatetime from "./form/yhmDatetime.vue";
8
9
  import yhmRadio from "./form/yhmRadio.vue";
@@ -11,6 +12,11 @@ import yhmSelect from "./form/yhmSelect.vue";
11
12
  import yhmInput from "./form/yhmInput.vue";
12
13
  import yhmSwitch from "./form/yhmSwitch.vue";
13
14
  import yhmPassword from "./form/yhmPassword.vue";
15
+ import yhmCascader from "./form/yhmCascader.vue";
16
+ import yhmRate from "./form/yhmRate.vue";
17
+ import yhmSignature from "./form/yhmSignature.vue";
18
+ import yhmSlider from "./form/yhmSlider.vue";
19
+ import yhmStepper from "./form/yhmStepper.vue";
14
20
  import vant from "vant";
15
21
  import "vant/lib/index.css";
16
22
  import "yh-mobile-components/custom.scss";
@@ -22,6 +28,7 @@ export default {
22
28
  app.component("yhm-tabs", yhmTabs);
23
29
  app.component("yhm-info", yhmInfo);
24
30
  app.component("yhm-info-item", yhmInfoItem);
31
+ app.component("yhm-table", yhmTable);
25
32
  app.component("yhm-form", yhmForm);
26
33
  app.component("yhm-datetime", yhmDatetime);
27
34
  app.component("yhm-radio", yhmRadio);
@@ -30,6 +37,11 @@ export default {
30
37
  app.component("yhm-select", yhmSelect);
31
38
  app.component("yhm-switch", yhmSwitch);
32
39
  app.component("yhm-password", yhmPassword);
40
+ app.component("yhm-cascader", yhmCascader);
41
+ app.component("yhm-rate", yhmRate);
42
+ app.component("yhm-signature", yhmSignature);
43
+ app.component("yhm-slider", yhmSlider);
44
+ app.component("yhm-stepper", yhmStepper);
33
45
  app.use(vant);
34
46
  },
35
47
  };
package/info/yhmList.vue CHANGED
@@ -54,12 +54,14 @@
54
54
  </template>
55
55
  </yhm-info>
56
56
  <yhm-info class="yhm-list-item-actions">
57
- <div
58
- v-for="btn in listConfig.btns"
59
- :class="`yhm-list-btn${btn.type ? ' ' + btn.type : ''}`"
60
- @click="() => btn.callback(row)">
61
- {{ btn.text }}
62
- </div>
57
+ <template v-for="btn in listConfig.btns">
58
+ <div
59
+ v-if="!item.show || (item.show && item.show(row))"
60
+ :class="`yhm-list-btn${btn.type ? ' ' + btn.type : ''}`"
61
+ @click="() => btn.callback(row)">
62
+ {{ btn.text }}
63
+ </div>
64
+ </template>
63
65
  </yhm-info>
64
66
  </template>
65
67
  </van-list>
@@ -163,6 +165,10 @@ onMounted(() => {
163
165
  });
164
166
 
165
167
  onActivated(() => {});
168
+
169
+ defineExpose({
170
+ getList,
171
+ });
166
172
  </script>
167
173
  <style lang="scss">
168
174
  .yhm-list-container {
@@ -0,0 +1,87 @@
1
+ <template>
2
+ <section class="yhm-table-container">
3
+ <table class="yhm-table">
4
+ <colgroup>
5
+ <col
6
+ v-for="col in columns"
7
+ :width="col.width"
8
+ :align="col.align" />
9
+ </colgroup>
10
+ <tr>
11
+ <th
12
+ v-for="column in columns"
13
+ :align="column.align">
14
+ {{ column.label }}
15
+ </th>
16
+ </tr>
17
+ <tr v-for="row in data">
18
+ <td
19
+ v-for="column in columns"
20
+ :align="column.align">
21
+ {{ row[column.prop] }}
22
+ </td>
23
+ </tr>
24
+ </table>
25
+ </section>
26
+ </template>
27
+ <script setup lang="ts">
28
+ import { computed } from "vue";
29
+ import { ColumnItem } from "../types";
30
+
31
+ const props = withDefaults(
32
+ defineProps<{
33
+ data: any[];
34
+ hasIndex?: boolean;
35
+ columns: ColumnItem[];
36
+ }>(),
37
+ {
38
+ data: [],
39
+ hasIndex: false,
40
+ columns: [],
41
+ }
42
+ );
43
+
44
+ const tableWidth = computed(() => {
45
+ let width = props.columns.reduce((accumulator, column) => {
46
+ let w = parseInt(column.width);
47
+ if (!isNaN(w)) {
48
+ w = 0;
49
+ }
50
+ return accumulator + w;
51
+ }, 0);
52
+
53
+ return width === 0 ? "100%" : `${width}px`;
54
+ });
55
+ </script>
56
+ <style lang="scss">
57
+ .yhm-table-container {
58
+ width: 100%;
59
+ overflow-x: auto;
60
+ .yhm-table {
61
+ table-layout: fixed;
62
+ border-collapse: collapse;
63
+ border-spacing: 0;
64
+ min-width: 100%;
65
+ width: v-bind(tableWidth);
66
+ position: relative;
67
+ background-color: var(--van-white);
68
+ th,
69
+ td {
70
+ box-sizing: border-box;
71
+ padding: 10px 16px;
72
+ line-height: 24px;
73
+ font-size: var(--van-font-size-md);
74
+ }
75
+ th {
76
+ color: var(--van-text-color);
77
+ font-weight: 400;
78
+ }
79
+ td {
80
+ color: var(--van-text-color-2);
81
+ }
82
+ tr + tr {
83
+ border-top: 1px solid var(--van-gray-1);
84
+ }
85
+ }
86
+ }
87
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yh-mobile-components",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "移动端组件封装及配置化需求",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/types.ts CHANGED
@@ -17,6 +17,10 @@ export interface ListBtn {
17
17
  text: string;
18
18
  /** 按钮被点击后的回调函数 */
19
19
  callback: (row) => void;
20
+ /** 是否显示
21
+ * @param row 当前行数据
22
+ */
23
+ show?: (row: T) => boolean;
20
24
  }
21
25
 
22
26
  /** 列表对象字段 */
@@ -122,3 +126,12 @@ export interface ConfigFormItem {
122
126
  /** 不同类型表单项的个性化配置 */
123
127
  config: ConfigFormItem["type"] extends DateTimeType ? DatetimeConfig : ConfigFormItem["type"] extends "checkbox" ? CheckboxConfig : ConfigFormItem["type"] extends "radio" ? RadioConfig : ConfigFormItem["type"] extends "select" ? SelectConfig : ConfigFormItem["type"] extends "switch" ? SwitchConfig : {};
124
128
  }
129
+
130
+ /** 表格单元格 */
131
+ export interface ColumnItem {
132
+ /** 表头名 */
133
+ label: string;
134
+ prop: string;
135
+ width: string;
136
+ align: "left" | "center" | "right";
137
+ }