hw-cus-ui 1.0.24 → 1.1.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.
package/HwBtn/HwBtn.vue CHANGED
@@ -1,16 +1,16 @@
1
- <template>
2
- <div class="btn">我的按钮</div>
3
- </template>
4
-
5
- <script setup lang="ts">
6
-
7
- </script>
8
-
9
- <style scoped>
10
- .btn {
11
- width: 100px;
12
- height: 100px;
13
- background-color: red;
14
- color: #ffffff;
15
- }
16
- </style>
1
+ <template>
2
+ <div class="btn">我的按钮</div>
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+
7
+ </script>
8
+
9
+ <style scoped>
10
+ .btn {
11
+ width: 100px;
12
+ height: 100px;
13
+ background-color: red;
14
+ color: #ffffff;
15
+ }
16
+ </style>
package/HwBtn/index.ts CHANGED
@@ -1,10 +1,10 @@
1
- // index.ts
2
- import type { App } from 'vue'
3
- import HwBtn from "./HwBtn.vue"
4
-
5
- // 使用install方法,在app.use挂载
6
- HwBtn.install = (app: App) => {
7
- app.component(HwBtn.__name as string, HwBtn) //注册组件
8
- }
9
-
10
- export default HwBtn
1
+ // index.ts
2
+ import type { App } from 'vue'
3
+ import HwBtn from "./HwBtn.vue"
4
+
5
+ // 使用install方法,在app.use挂载
6
+ HwBtn.install = (app: App) => {
7
+ app.component(HwBtn.__name as string, HwBtn) //注册组件
8
+ }
9
+
10
+ export default HwBtn
@@ -0,0 +1,117 @@
1
+ <template>
2
+ <view class="bn-select" :style="{ marginTop: marginTop }">
3
+ <view class="select-item">
4
+ <view>
5
+ <!-- 标签区域:显示字段标签和必填标识 -->
6
+ <view class="label" :style="{ color: types === 'detail' ? 'rgba(23, 26, 29, 0.6)' : 'rgba(23, 26, 29, 1)' }">
7
+ <text style="color: red" v-if="required">*</text>
8
+ {{ label }}
9
+ </view>
10
+ <!-- 编辑模式下显示复选框组件 -->
11
+ <slot>
12
+ <uni-data-checkbox
13
+ class="value"
14
+ v-if="pageType !== 'detail'"
15
+ v-model="value"
16
+ :localdata="localdata"
17
+ v-bind="$attrs"
18
+ />
19
+ </slot>
20
+
21
+ <!-- 详情模式下显示选中项的文本 -->
22
+ <view
23
+ class="value"
24
+ v-if="pageType === 'detail'"
25
+ :style="{ color: types === 'detail' ? 'rgba(23, 26, 29, 0.6)' : 'rgba(23, 26, 29, 1)' }"
26
+ >
27
+ {{ getValue(value) }}
28
+ </view>
29
+ </view>
30
+ </view>
31
+ </view>
32
+ </template>
33
+
34
+ <script lang="ts" setup>
35
+ /**
36
+ * 双向绑定的值,可以是字符串或数字类型
37
+ */
38
+ const value = defineModel<string | number>();
39
+
40
+ /**
41
+ * 组件属性接口定义
42
+ */
43
+ interface Props {
44
+ /**
45
+ * 上边距,默认为 20px
46
+ */
47
+ marginTop?: string;
48
+ /**
49
+ * 页面类型,用于区分编辑页面还是详情页面
50
+ */
51
+ pageType?: string;
52
+ /**
53
+ * 字段标签名称(必填)
54
+ */
55
+ label: string;
56
+ /**
57
+ * 类型标识,用于控制样式显示
58
+ */
59
+ types?: string;
60
+ /**
61
+ * 是否必填项,true时会显示红色星号
62
+ */
63
+ required?: boolean;
64
+ /**
65
+ * 下拉选项数据列表,每项应包含value和text属性
66
+ */
67
+ localdata?: any[];
68
+ }
69
+
70
+ /**
71
+ * 定义组件接收的属性
72
+ */
73
+ const props = defineProps<Props>();
74
+
75
+ /**
76
+ * 解构赋值设置默认值
77
+ */
78
+ const { label = '', marginTop = '20px', pageType = 'checkbox', types = 'add' } = props;
79
+
80
+ /**
81
+ * 根据选中的值获取对应的文本显示
82
+ * @param val 当前选中的值
83
+ * @returns 对应的文本内容,未找到则返回空字符串
84
+ */
85
+ const getValue = (val: any) => {
86
+ if (val) {
87
+ return props.localdata?.find((item) => item.value === val)?.text;
88
+ }
89
+ return '';
90
+ };
91
+ </script>
92
+
93
+ <style lang="scss" scoped>
94
+ .bn-select {
95
+ width: 100%;
96
+ border-bottom: 1rpx solid rgba(17, 31, 44, 0.12);
97
+ .select-item {
98
+ .label {
99
+ font-size: 34rpx;
100
+ letter-spacing: 0px;
101
+ line-height: 44rpx;
102
+ height: 44rpx;
103
+ color: rgba(23, 26, 29, 1);
104
+ }
105
+ .value {
106
+ font-size: 34rpx;
107
+ padding: 20rpx 0;
108
+ }
109
+ }
110
+ ::v-deep .checklist-text {
111
+ font-size: 34rpx !important;
112
+ }
113
+ ::v-deep .uni-data-checklist .checklist-group .checklist-box {
114
+ margin: 10rpx 40rpx 10rpx 0rpx !important;
115
+ }
116
+ }
117
+ </style>
@@ -0,0 +1,111 @@
1
+ # HwCheckbox 组件使用说明
2
+
3
+ HwCheckbox 是一个复选框组件,支持编辑模式和详情模式,可以显示复选框或只读文本。
4
+
5
+ ## 功能特性
6
+
7
+ - 支持编辑模式和详情模式
8
+ - 支持双向数据绑定
9
+ - 支持自定义选项数据
10
+ - 支持必填标识显示
11
+ - 支持自定义样式
12
+
13
+ ## 属性 (Props)
14
+
15
+ | 属性 | 类型 | 默认值 | 说明 |
16
+ |------|------|--------|------|
17
+ | [marginTop](file:///e:/temp/my-components/src/components/HwCheckbox/HwCheckbox.vue#L41-L43) | string | '20px' | 上边距 |
18
+ | [pageType](file:///e:/temp/my-components/src/components/HwCheckbox/HwCheckbox.vue#L44-L46) | string | 'checkbox' | 页面类型,用于区分编辑页面还是详情页面 |
19
+ | [label](file:///e:/temp/my-components/src/components/HwCheckbox/HwCheckbox.vue#L47-L49) | string | - | 字段标签名称(必填) |
20
+ | [types](file:///e:/temp/my-components/src/components/HwCheckbox/HwCheckbox.vue#L50-L52) | string | 'add' | 类型标识,用于控制样式显示 |
21
+ | [required](file:///e:/temp/my-components/src/components/HwCheckbox/HwCheckbox.vue#L53-L55) | boolean | false | 是否必填项,true时会显示红色星号 |
22
+ | [localdata](file:///e:/temp/my-components/src/components/HwCheckbox/HwCheckbox.vue#L56-L59) | Array&lt;any&gt; | - | 下拉选项数据列表,每项应包含value和text属性 |
23
+
24
+ ## 事件 (Events)
25
+
26
+ | 事件名 | 参数 | 说明 |
27
+ |-------|------|------|
28
+ | update:modelValue | (value: string \| number) | 当值变化时触发 |
29
+
30
+ ## 使用示例
31
+
32
+ ### 基础用法
33
+
34
+ ```vue
35
+ <template>
36
+ <HwCheckbox
37
+ v-model="checkboxValue"
38
+ label="选择项"
39
+ :localdata="checkboxOptions"
40
+ />
41
+ </template>
42
+
43
+ <script setup>
44
+ import { ref } from 'vue';
45
+ import HwCheckbox from '@/components/HwCheckbox/HwCheckbox.vue';
46
+
47
+ const checkboxValue = ref('');
48
+ const checkboxOptions = [
49
+ { value: 'option1', text: '选项1' },
50
+ { value: 'option2', text: '选项2' },
51
+ { value: 'option3', text: '选项3' }
52
+ ];
53
+ </script>
54
+ ```
55
+
56
+ ### 详情模式
57
+
58
+ ```vue
59
+ <template>
60
+ <HwCheckbox
61
+ v-model="checkboxValue"
62
+ label="选择项"
63
+ :localdata="checkboxOptions"
64
+ pageType="detail"
65
+ />
66
+ </template>
67
+
68
+ <script setup>
69
+ import { ref } from 'vue';
70
+ import HwCheckbox from '@/components/HwCheckbox/HwCheckbox.vue';
71
+
72
+ const checkboxValue = ref('option1');
73
+ const checkboxOptions = [
74
+ { value: 'option1', text: '选项1' },
75
+ { value: 'option2', text: '选项2' },
76
+ { value: 'option3', text: '选项3' }
77
+ ];
78
+ </script>
79
+ ```
80
+
81
+ ### 必填项
82
+
83
+ ```vue
84
+ <template>
85
+ <HwCheckbox
86
+ v-model="checkboxValue"
87
+ label="必填选择项"
88
+ :required="true"
89
+ :localdata="checkboxOptions"
90
+ />
91
+ </template>
92
+
93
+ <script setup>
94
+ import { ref } from 'vue';
95
+ import HwCheckbox from '@/components/HwCheckbox/HwCheckbox.vue';
96
+
97
+ const checkboxValue = ref('');
98
+ const checkboxOptions = [
99
+ { value: 'option1', text: '选项1' },
100
+ { value: 'option2', text: '选项2' }
101
+ ];
102
+ </script>
103
+ ```
104
+
105
+ ## 注意事项
106
+
107
+ 1. 组件使用了 uni-data-checkbox 作为基础组件
108
+ 2. 在详情模式下,组件只显示选中项的文本,不提供编辑功能
109
+ 3. [localdata](file:///e:/temp/my-components/src/components/HwCheckbox/HwCheckbox.vue#L56-L59) 属性的每个选项对象需要包含 [value](file:///e:/temp/my-components/src/components/HwPickerTree/HwPickerTree.vue#L35-L40) 和 text 属性
110
+ 4. [pageType](file:///e:/temp/my-components/src/components/HwCheckbox/HwCheckbox.vue#L44-L46) 设置为 'detail' 时会显示为只读的详情模式
111
+ 5. 组件支持通过插槽自定义内容
@@ -0,0 +1,10 @@
1
+ // index.ts
2
+ import type { App } from 'vue';
3
+ import HwCheckbox from './HwCheckbox.vue';
4
+
5
+ // 使用install方法,在app.use挂载
6
+ HwCheckbox.install = (app: App) => {
7
+ app.component(HwCheckbox.__name as string, HwCheckbox); //注册组件
8
+ };
9
+
10
+ export default HwCheckbox;
@@ -0,0 +1,127 @@
1
+ # HwDraggableBottomPopup 组件使用说明
2
+
3
+ HwDraggableBottomPopup 是一个可拖拽的底部弹窗组件,支持触摸拖拽调整位置,适用于需要用户交互调整内容区域的场景。
4
+
5
+ ## 功能特性
6
+
7
+ - 支持触摸拖拽调整弹窗位置
8
+ - 可自定义弹窗高度
9
+ - 支持拖拽过程中实时调整内容区域高度
10
+ - 防抖处理确保性能
11
+ - 灵活的内容插槽
12
+
13
+ ## 属性 (Props)
14
+
15
+ | 属性 | 类型 | 默认值 | 说明 |
16
+ |------|------|--------|------|
17
+ | [heightCalc](file:///e:/temp/my-components/src/components/HwDraggableBottomPopup/HwDraggableBottomPopup.vue#L31-L35) | String | '0.4' | 弹窗高度计算比例,相对于屏幕高度的百分比 |
18
+ | [isDrag](file:///e:/temp/my-components/src/components/HwDraggableBottomPopup/HwDraggableBottomPopup.vue#L36-L40) | Boolean | true | 是否启用拖拽功能 |
19
+
20
+ ## 事件 (Events)
21
+
22
+ | 事件名 | 参数 | 说明 |
23
+ |-------|------|------|
24
+ | changeTop | (top: number) | 拖拽过程中顶部位置变化时触发 |
25
+
26
+ ## 插槽 (Slots)
27
+
28
+ | 插槽名 | 说明 |
29
+ |--------|------|
30
+ | default | 默认插槽,用于放置弹窗内容 |
31
+
32
+ ## 使用示例
33
+
34
+ ### 基础用法
35
+
36
+ ```vue
37
+ <template>
38
+ <view>
39
+ <HwDraggableBottomPopup>
40
+ <view class="popup-content">
41
+ <p>这里是弹窗内容</p>
42
+ <p>可以放置任何内容</p>
43
+ </view>
44
+ </HwDraggableBottomPopup>
45
+ </view>
46
+ </template>
47
+
48
+ <script setup>
49
+ import HwDraggableBottomPopup from '@/components/HwDraggableBottomPopup/HwDraggableBottomPopup.vue';
50
+ </script>
51
+
52
+ <style>
53
+ .popup-content {
54
+ padding: 20rpx;
55
+ height: 100%;
56
+ }
57
+ </style>
58
+ ```
59
+
60
+ ### 自定义高度
61
+
62
+ ```vue
63
+ <template>
64
+ <view>
65
+ <HwDraggableBottomPopup :heightCalc="'0.6'">
66
+ <view class="popup-content">
67
+ <p>初始高度为屏幕高度的60%</p>
68
+ </view>
69
+ </HwDraggableBottomPopup>
70
+ </view>
71
+ </template>
72
+
73
+ <script setup>
74
+ import HwDraggableBottomPopup from '@/components/HwDraggableBottomPopup/HwDraggableBottomPopup.vue';
75
+ </script>
76
+ ```
77
+
78
+ ### 禁用拖拽
79
+
80
+ ```vue
81
+ <template>
82
+ <view>
83
+ <HwDraggableBottomPopup :isDrag="false">
84
+ <view class="popup-content">
85
+ <p>此弹窗不可拖拽</p>
86
+ </view>
87
+ </HwDraggableBottomPopup>
88
+ </view>
89
+ </template>
90
+
91
+ <script setup>
92
+ import HwDraggableBottomPopup from '@/components/HwDraggableBottomPopup/HwDraggableBottomPopup.vue';
93
+ </script>
94
+ ```
95
+
96
+ ### 监听位置变化
97
+
98
+ ```vue
99
+ <template>
100
+ <view>
101
+ <HwDraggableBottomPopup @changeTop="onTopChange">
102
+ <view class="popup-content">
103
+ <p>拖拽弹窗查看位置变化</p>
104
+ </view>
105
+ </HwDraggableBottomPopup>
106
+ </view>
107
+ </template>
108
+
109
+ <script setup>
110
+ import { ref } from 'vue';
111
+ import HwDraggableBottomPopup from '@/components/HwDraggableBottomPopup/HwDraggableBottomPopup.vue';
112
+
113
+ const onTopChange = (top) => {
114
+ console.log('弹窗顶部位置:', top);
115
+ };
116
+ </script>
117
+ ```
118
+
119
+ ## 注意事项
120
+
121
+ 1. 组件使用了 uni-app 的触摸事件和系统信息API
122
+ 2. 弹窗默认从屏幕底部开始,初始位置在屏幕外
123
+ 3. 拖拽功能通过触摸事件实现,支持触摸开始、移动和结束
124
+ 4. 弹窗内容区域高度会根据拖拽位置自动调整
125
+ 5. 组件使用了防抖函数优化性能,避免频繁更新内容区域高度
126
+ 6. 当启用拖拽功能时,组件会添加圆角边框以提供更好的视觉效果
127
+ 7. 组件内部使用了 flex 布局,内容区域会自动适应可用空间
@@ -0,0 +1,10 @@
1
+ // index.ts
2
+ import type { App } from 'vue';
3
+ import HwDraggableBottomPopup from './HwDraggableBottomPopup.vue';
4
+
5
+ // 使用install方法,在app.use挂载
6
+ HwDraggableBottomPopup.install = (app: App) => {
7
+ app.component(HwDraggableBottomPopup.__name as string, HwDraggableBottomPopup); //注册组件
8
+ };
9
+
10
+ export default HwDraggableBottomPopup;