@tplc/wot 0.1.76 → 0.1.78

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 CHANGED
@@ -2,6 +2,36 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.1.78](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.1.77...v0.1.78) (2025-04-07)
6
+
7
+
8
+ ### ✨ Features | 新功能
9
+
10
+ * 调整版本 ([6a46a2c](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/6a46a2c1b359c1777d548658fa5fc87cbc1ce29a))
11
+
12
+ ### [0.1.77](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.4.61...v0.1.77) (2025-04-07)
13
+
14
+
15
+ ### 🐛 Bug Fixes | Bug 修复
16
+
17
+ * img ([ba700e5](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/ba700e50dc529c9f5b9e6386c61aa0747bc8b519))
18
+
19
+
20
+ ### 🚀 Chore | 构建/工程依赖/工具
21
+
22
+ * **release:** 0.4.62 ([a411974](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/a411974be01305a0182c4dca3a08db449f190327))
23
+ * **release:** 0.4.63 ([d86180a](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/d86180ad51bc82e8a207f3d56fba38e5b4e42910))
24
+
25
+
26
+ ### ✨ Features | 新功能
27
+
28
+ * button 配置 ([f01230d](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/f01230d73ea058222495648378389c5dcaec0ba9))
29
+ * 修改 rate ([afc9da2](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/afc9da279a4a0f3425e6425cec8936fdc646936d))
30
+ * 修改样式 ([10f7b8d](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/10f7b8d22dafe59374fac3728917eaef835eac72))
31
+ * 暂时支持搜索 ([a592c77](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/a592c77a9c162b73e223c785b7932ec17253f4ea))
32
+ * 调整布局 ([497999f](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/497999f86ec4e6461f747eda7914cc2c5e4b1290))
33
+ * 调整策略 ([55095bb](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/commit/55095bb55a49651ba2e5b75bc780ebb78d697b3a))
34
+
5
35
  ### [0.1.76](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.4.32...v0.1.76) (2025-03-29)
6
36
 
7
37
  ### [0.1.75](http://gitlab888.30jia.com.cn/bhBank/zero-code-pro/compare/v0.1.74...v0.1.75) (2025-03-27)
@@ -60,6 +60,15 @@
60
60
  color: #fff;
61
61
  background: $-calendar-active-color;
62
62
  border-radius: $-calendar-active-border;
63
+ .text-price {
64
+ color: #fff;
65
+ }
66
+ }
67
+ .wd-month__day-bottom,
68
+ .wd-month__day-top,
69
+ .wd-month__day-floor,
70
+ .wd-month__day-text {
71
+ color: #fff !important;
63
72
  }
64
73
  }
65
74
 
@@ -93,6 +102,12 @@
93
102
  .wd-month__day-text-custom {
94
103
  color: #fff;
95
104
  }
105
+ .wd-month__day-bottom,
106
+ .wd-month__day-top,
107
+ .wd-month__day-floor,
108
+ .wd-month__day-text {
109
+ color: #fff !important;
110
+ }
96
111
  }
97
112
 
98
113
  @include when(end) {
@@ -115,6 +130,12 @@
115
130
  .wd-month__day-text-custom {
116
131
  color: #fff;
117
132
  }
133
+ .wd-month__day-bottom,
134
+ .wd-month__day-top,
135
+ .wd-month__day-floor,
136
+ .wd-month__day-text {
137
+ color: #fff !important;
138
+ }
118
139
  }
119
140
 
120
141
  @include when(same) {
@@ -52,4 +52,4 @@ export const imgProps = {
52
52
  enablePreview: makeBooleanProp(false),
53
53
 
54
54
  lazyPlaceWidth: numericProp,
55
- }
55
+ }
@@ -55,7 +55,7 @@ const emit = defineEmits(['error', 'click', 'load'])
55
55
 
56
56
  const rootStyle = computed(() => {
57
57
  const style: Record<string, string | number> = {}
58
- if (isDef(props.height)) {
58
+ if (isDef(props.height) && props.height !== 'auto') {
59
59
  style.height = addUnit(props.height)
60
60
  }
61
61
  if (isDef(props.width)) {
@@ -1,24 +1,25 @@
1
- @import './../common/abstracts/_mixin';
2
- @import './../common/abstracts/variable';
1
+ @import './../common/abstracts/_mixin.scss';
2
+ @import './../common/abstracts/variable.scss';
3
3
 
4
4
  @include b(rate) {
5
5
  display: inline-block;
6
- line-height: 1;
7
6
  vertical-align: middle;
7
+ line-height: 1;
8
8
 
9
9
  @include e(item) {
10
10
  position: relative;
11
11
  display: inline-block;
12
+ touch-action: none; // 禁用默认触摸行为
12
13
  }
13
- @include e(item-star) {
14
- display: inline-block;
15
- vertical-align: top;
16
-
17
- @include m(active) {
18
- position: absolute;
19
- top: 0;
20
- left: 0;
21
- overflow: hidden;
22
- }
14
+ @include edeep(item-star) {
15
+ -webkit-background-clip: text !important;
16
+ color: transparent;
17
+ }
18
+ @include e(item-half) {
19
+ position: absolute;
20
+ left: 0;
21
+ top: 0;
22
+ overflow: hidden;
23
+ width: 50%;
23
24
  }
24
25
  }
@@ -88,4 +88,11 @@ export const rateProps = {
88
88
  disabledColor: makeStringProp(
89
89
  'linear-gradient(315deg, rgba(177,177,177,1) 0%,rgba(199,199,199,1) 100%)',
90
90
  ),
91
+
92
+ /**
93
+ * 是否允许半选
94
+ * 类型: boolean
95
+ * 默认值: false
96
+ */
97
+ allowHalf: makeBooleanProp(false),
91
98
  }
@@ -1,21 +1,26 @@
1
1
  <template>
2
- <view :class="`wd-rate ${customClass}`" :style="customStyle">
2
+ <view :class="`wd-rate ${customClass}`" :style="customStyle" @touchmove="onTouchMove">
3
3
  <view
4
4
  v-for="(rate, index) in rateList"
5
5
  :key="index"
6
6
  :data-index="index"
7
7
  :style="{ 'margin-right': index == rateList.length - 1 ? 0 : space }"
8
8
  class="wd-rate__item"
9
- @click="changeRate(index)"
10
9
  >
11
- <view class="wd-rate__item-star" :style="{ width: size, height: size }">
12
- <wd-icon :name="icon" :size="size" :custom-style="iconStyle" />
13
- </view>
14
- <view
15
- class="wd-rate__item-star wd-rate__item-star--active"
16
- :style="{ width: rate, height: size }"
17
- >
18
- <wd-icon :name="activeIcon" :size="size" :custom-style="iconActiveStyle" />
10
+ <wd-icon
11
+ custom-class="wd-rate__item-star"
12
+ :name="isActive(rate) ? activeIcon : icon"
13
+ :size="size"
14
+ :custom-style="rate === '100%' ? iconActiveStyle : iconStyle"
15
+ @click="changeRate(index, false)"
16
+ />
17
+ <view v-if="props.allowHalf" class="wd-rate__item-half" @click.stop="changeRate(index, true)">
18
+ <wd-icon
19
+ custom-class="wd-rate__item-star"
20
+ :name="isActive(rate) ? activeIcon : icon"
21
+ :size="size"
22
+ :custom-style="rate !== '0' ? iconActiveStyle : iconStyle"
23
+ />
19
24
  </view>
20
25
  </view>
21
26
  </view>
@@ -32,8 +37,11 @@ export default {
32
37
  }
33
38
  </script>
34
39
  <script lang="ts" setup>
35
- import { computed, ref, watch } from 'vue'
40
+ import wdIcon from '../wd-icon/wd-icon.vue'
41
+ import { computed, getCurrentInstance, ref, watch } from 'vue'
36
42
  import { rateProps } from './types'
43
+ import { getRect } from '../common/util'
44
+ const { proxy } = getCurrentInstance() as any
37
45
 
38
46
  const props = defineProps(rateProps)
39
47
  const emit = defineEmits(['update:modelValue', 'change'])
@@ -42,11 +50,11 @@ const rateList = ref<Array<string>>([])
42
50
  const activeValue = ref<string>('')
43
51
 
44
52
  const iconStyle = computed(() => {
45
- return `background:${props.color}; -webkit-background-clip: text; color: transparent`
53
+ return `background:${props.color};`
46
54
  })
47
55
 
48
56
  const iconActiveStyle = computed(() => {
49
- return `background:${props.disabled ? props.disabledColor : activeValue.value}; -webkit-background-clip: text; color: transparent`
57
+ return `background:${props.disabled ? props.disabledColor : activeValue.value};`
50
58
  })
51
59
 
52
60
  watch(
@@ -74,11 +82,16 @@ watch(
74
82
  },
75
83
  )
76
84
 
85
+ // 当前选项是否为激活状态
86
+ const isActive = (rate: string) => {
87
+ return rate !== '0'
88
+ }
89
+
77
90
  /**
78
91
  * @description 计算当前应当展示的rate数量
79
92
  */
80
93
  function computeRateList() {
81
- const { modelValue, num } = props
94
+ const { modelValue, num, allowHalf } = props
82
95
  // value和num都准备好才能计算
83
96
  if (modelValue === null || !num) return
84
97
  if (typeof modelValue !== 'number') {
@@ -86,13 +99,12 @@ function computeRateList() {
86
99
  return
87
100
  }
88
101
  const tempRateList: string[] = []
89
- const fullLength = Math.ceil(modelValue) - 1
102
+ const fullLength = Math.floor(modelValue)
90
103
  for (let i = 0; i < num; i++) {
91
104
  if (i < fullLength) {
92
105
  tempRateList.push('100%')
93
- } else if (i === fullLength) {
94
- const rate = modelValue - fullLength > 0.5 ? 1 : 0.5
95
- tempRateList.push(rate * 100 + '%')
106
+ } else if (i === fullLength && allowHalf && modelValue % 1 !== 0) {
107
+ tempRateList.push('50%')
96
108
  } else {
97
109
  tempRateList.push('0')
98
110
  }
@@ -116,16 +128,33 @@ function computeActiveValue() {
116
128
  }
117
129
  /**
118
130
  * @description 点击icon触发组件的change事件
119
- * @param Event
120
131
  */
121
- function changeRate(index: number) {
132
+ function changeRate(index: number, isHalf: boolean) {
122
133
  if (props.readonly || props.disabled) return
123
- emit('update:modelValue', index + 1)
134
+ const value = isHalf ? index + 0.5 : index + 1
135
+ emit('update:modelValue', value)
124
136
  emit('change', {
125
- value: index + 1,
137
+ value,
138
+ })
139
+ }
140
+
141
+ async function onTouchMove(event: TouchEvent) {
142
+ const { clientX } = event.touches[0]
143
+ const rateItems = await getRect('.wd-rate__item', true, proxy)
144
+ const targetIndex = Array.from(rateItems).findIndex((rect) => {
145
+ return clientX >= rect.left! && clientX <= rect.right!
126
146
  })
147
+ if (targetIndex !== -1) {
148
+ const target = rateItems[targetIndex]
149
+ const itemWidth = target.width!
150
+ const isHalf = props.allowHalf && clientX - target.left! < itemWidth / 2
151
+ const value = isHalf ? targetIndex + 0.5 : targetIndex + 1
152
+ if (value >= 0.5) {
153
+ changeRate(targetIndex, isHalf)
154
+ }
155
+ }
127
156
  }
128
157
  </script>
129
158
  <style lang="scss" scoped>
130
- @import './index';
159
+ @import './index.scss';
131
160
  </style>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "@tplc/wot",
3
3
  "name": "@tplc/wot",
4
- "version": "0.1.76",
4
+ "version": "0.1.78",
5
5
  "keywords": [
6
6
  "wot-design-uni",
7
7
  "国际化",
@@ -99,6 +99,15 @@ export declare const rateProps: {
99
99
  type: PropType<string>
100
100
  default: string
101
101
  }
102
+ /**
103
+ * 是否允许半选
104
+ * 类型: boolean
105
+ * 默认值: false
106
+ */
107
+ allowHalf: {
108
+ type: BooleanConstructor
109
+ default: boolean
110
+ }
102
111
  customStyle: {
103
112
  type: PropType<string>
104
113
  default: string
@@ -44,6 +44,10 @@ declare const _default: import('vue').DefineComponent<
44
44
  type: import('vue').PropType<string>
45
45
  default: string
46
46
  }
47
+ allowHalf: {
48
+ type: BooleanConstructor
49
+ default: boolean
50
+ }
47
51
  customStyle: {
48
52
  type: import('vue').PropType<string>
49
53
  default: string
@@ -111,6 +115,10 @@ declare const _default: import('vue').DefineComponent<
111
115
  type: import('vue').PropType<string>
112
116
  default: string
113
117
  }
118
+ allowHalf: {
119
+ type: BooleanConstructor
120
+ default: boolean
121
+ }
114
122
  customStyle: {
115
123
  type: import('vue').PropType<string>
116
124
  default: string
@@ -138,6 +146,7 @@ declare const _default: import('vue').DefineComponent<
138
146
  num: number
139
147
  activeColor: string | string[]
140
148
  disabledColor: string
149
+ allowHalf: boolean
141
150
  },
142
151
  {}
143
152
  >