This commit is contained in:
pengxiaolong
2025-05-21 17:03:19 +08:00
parent 829199a197
commit 0b9353de84
96 changed files with 9172 additions and 30 deletions

View File

@@ -0,0 +1,191 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "wht-select",
props: {
options: {
type: Array,
default: () => []
},
value: {
type: [String, Number],
default: ""
},
placeholder: {
type: String,
default: "请选择"
},
disabled: {
type: Boolean,
default: false
},
clearable: {
type: Boolean,
default: false
},
// 样式相关的props
height: {
type: Number,
default: 40
},
fontSize: {
type: Number,
default: 14
},
borderColor: {
type: String,
default: "#dcdfe6"
},
borderRadius: {
type: Number,
default: 4
},
backgroundColor: {
type: String,
default: "#ffffff"
},
textColor: {
type: String,
default: "#606266"
},
placeholderColor: {
type: String,
default: "#c0c4cc"
},
activeColor: {
type: String,
default: "#409eff"
},
filterable: {
type: Boolean,
default: false
},
searchPlaceholder: {
type: String,
default: "请输入搜索内容"
}
},
data() {
return {
currentValue: "",
isOpen: false,
searchQuery: ""
};
},
computed: {
currentLabel() {
const option = this.options.find((item) => item.value === this.currentValue);
return option ? option.label : "";
},
filteredOptions() {
if (!this.filterable || !this.searchQuery) {
return this.options;
}
return this.options.filter(
(item) => item.label.toLowerCase().includes(this.searchQuery.toLowerCase())
);
}
},
watch: {
value: {
handler(newVal) {
this.currentValue = newVal;
},
immediate: true
}
},
methods: {
togglePicker() {
if (this.disabled)
return;
this.isOpen = !this.isOpen;
if (!this.isOpen) {
this.searchQuery = "";
}
},
selectOption(item, index) {
if (item.disabled)
return;
this.currentValue = item.value;
this.searchQuery = "";
this.$emit("input", item.value);
this.$emit("change", item);
this.isOpen = false;
},
clearValue(e) {
this.currentValue = "";
this.searchQuery = "";
this.$emit("input", "");
this.$emit("change", null);
this.$emit("clear");
},
onSearch() {
this.$emit("search", this.searchQuery);
},
handleFocus() {
if (!this.disabled) {
this.isOpen = true;
}
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: $props.filterable
}, $props.filterable ? {
b: $data.currentValue ? $options.currentLabel : $props.placeholder,
c: $props.fontSize + "px",
d: $data.currentValue ? $props.textColor : $props.placeholderColor,
e: common_vendor.o$1(() => {
}),
f: common_vendor.o$1([($event) => $data.searchQuery = $event.detail.value, (...args) => $options.onSearch && $options.onSearch(...args)]),
g: common_vendor.o$1((...args) => $options.handleFocus && $options.handleFocus(...args)),
h: $data.searchQuery
} : {
i: common_vendor.t($options.currentLabel || $props.placeholder),
j: $props.fontSize + "px",
k: $data.currentValue ? $props.textColor : $props.placeholderColor
}, {
l: $props.clearable && $data.currentValue && !$props.disabled
}, $props.clearable && $data.currentValue && !$props.disabled ? {
m: common_vendor.o$1((...args) => $options.clearValue && $options.clearValue(...args))
} : {
n: $props.placeholderColor
}, {
o: $data.isOpen ? 1 : "",
p: !$data.currentValue ? 1 : "",
q: $props.height + "px",
r: $props.backgroundColor,
s: $props.borderColor,
t: $props.borderRadius + "px",
v: common_vendor.o$1((...args) => $options.togglePicker && $options.togglePicker(...args)),
w: $data.isOpen
}, $data.isOpen ? common_vendor.e({
x: common_vendor.o$1((...args) => $options.togglePicker && $options.togglePicker(...args)),
y: $options.filteredOptions.length > 0
}, $options.filteredOptions.length > 0 ? {
z: common_vendor.f($options.filteredOptions, (item, index, i0) => {
return {
a: common_vendor.t(item.label),
b: item.value,
c: item.disabled ? 1 : "",
d: $data.currentValue === item.value ? 1 : "",
e: item.disabled ? $props.placeholderColor : $props.textColor,
f: $data.currentValue === item.value ? $props.activeColor + "20" : $props.backgroundColor,
g: common_vendor.o$1(($event) => $options.selectOption(item, index), item.value)
};
}),
A: $props.fontSize + "px"
} : {
B: $props.fontSize + "px",
C: $props.placeholderColor
}, {
D: $props.backgroundColor,
E: $props.borderRadius + "px"
}) : {}, {
F: $props.disabled ? 1 : ""
});
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-57f09195"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/wht-select/components/wht-select/wht-select.js.map

View File

@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1 @@
<view class="{{['wht-select-wrapper', 'data-v-57f09195', F && 'is-disabled']}}"><view class="{{['wht-select-inner', 'data-v-57f09195', o && 'is-active', p && 'is-placeholder']}}" style="{{'height:' + q + ';' + ('background-color:' + r) + ';' + ('border-color:' + s) + ';' + ('border-radius:' + t)}}" bindtap="{{v}}"><view class="wht-select-value data-v-57f09195"><input wx:if="{{a}}" class="wht-select-input data-v-57f09195" placeholder="{{b}}" style="{{'font-size:' + c + ';' + ('color:' + d)}}" catchtap="{{e}}" bindinput="{{f}}" bindfocus="{{g}}" value="{{h}}"/><text wx:else class="data-v-57f09195" style="{{'font-size:' + j + ';' + ('color:' + k)}}">{{i}}</text></view><view class="wht-select-suffix data-v-57f09195"><view wx:if="{{l}}" class="wht-select-clear data-v-57f09195" catchtap="{{m}}">×</view><view wx:else class="wht-select-arrow data-v-57f09195" style="{{'border-top-color:' + n}}"></view></view></view><view wx:if="{{w}}" class="select-dropdown data-v-57f09195"><view class="select-dropdown-mask data-v-57f09195" catchtap="{{x}}"></view><view class="select-dropdown-content data-v-57f09195" style="{{'background-color:' + D + ';' + ('border-radius:' + E)}}"><block wx:if="{{y}}"><view wx:for="{{z}}" wx:for-item="item" wx:key="b" class="{{['data-v-57f09195', item.c && 'disabled', item.d && 'active']}}" style="{{'font-size:' + A + ';' + ('color:' + item.e) + ';' + ('background-color:' + item.f)}}" catchtap="{{item.g}}">{{item.a}}</view></block><view wx:else class="select-dropdown-empty data-v-57f09195" style="{{'font-size:' + B + ';' + ('color:' + C)}}"> 暂无数据 </view></view></view></view>

View File

@@ -0,0 +1,181 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场https://ext.dcloud.net.cn上很多三方插件均使用了这些样式变量
* 如果你是插件开发者建议你使用scss预处理并在插件代码中直接使用这些变量无需 import 这个文件方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者插件使用者你可以通过修改这些变量来定制自己的插件主题实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.wht-select-wrapper.data-v-57f09195 {
width: 100%;
position: relative;
}
.wht-select-wrapper .wht-select-inner.data-v-57f09195 {
position: relative;
width: 100%;
border-width: 1px;
border-style: solid;
transition: all 0.2s;
cursor: pointer;
}
.wht-select-wrapper .wht-select-inner.is-active .wht-select-arrow.data-v-57f09195 {
transform: rotate(180deg);
}
.wht-select-wrapper .wht-select-value.data-v-57f09195 {
position: absolute;
left: 12px;
right: 30px;
top: 50%;
transform: translateY(-50%);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
height: 100%;
display: flex;
align-items: center;
}
.wht-select-wrapper .wht-select-suffix.data-v-57f09195 {
position: absolute;
right: 8px;
top: 50%;
transform: translateY(-50%);
display: flex;
align-items: center;
}
.wht-select-wrapper .wht-select-clear.data-v-57f09195 {
width: 16px;
height: 16px;
line-height: 16px;
text-align: center;
border-radius: 50%;
background-color: #c0c4cc;
color: #fff;
font-size: 12px;
cursor: pointer;
transition: all 0.2s;
}
.wht-select-wrapper .wht-select-clear.data-v-57f09195:hover {
background-color: #909399;
}
.wht-select-wrapper .wht-select-arrow.data-v-57f09195 {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid;
transition: transform 0.2s;
}
.wht-select-wrapper .select-dropdown.data-v-57f09195 {
position: absolute;
top: 100%;
left: 0;
width: 100%;
margin-top: 4px;
z-index: 999;
}
.wht-select-wrapper .select-dropdown-mask.data-v-57f09195 {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 998;
}
.wht-select-wrapper .select-dropdown-content.data-v-57f09195 {
position: relative;
max-height: 240px;
border: 1px solid #e4e7ed;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
z-index: 999;
overflow-y: auto;
}
.wht-select-wrapper .select-dropdown-content.data-v-57f09195::-webkit-scrollbar {
width: 6px;
}
.wht-select-wrapper .select-dropdown-content.data-v-57f09195::-webkit-scrollbar-thumb {
background-color: #e4e7ed;
border-radius: 3px;
}
.wht-select-wrapper .select-dropdown-content > view.data-v-57f09195 {
padding: 0 12px;
height: 36px;
line-height: 36px;
cursor: pointer;
}
.wht-select-wrapper .select-dropdown-content > view.disabled.data-v-57f09195 {
cursor: not-allowed;
}
.wht-select-wrapper .select-dropdown-content .select-dropdown-search.data-v-57f09195 {
padding: 8px;
border-bottom: 1px solid #e4e7ed;
}
.wht-select-wrapper .select-dropdown-content .select-dropdown-search input.data-v-57f09195 {
width: 100%;
height: 32px;
padding: 0 8px;
border: 1px solid #dcdfe6;
border-radius: 4px;
font-size: 14px;
}
.wht-select-wrapper .select-dropdown-content .select-dropdown-search input.data-v-57f09195:focus {
border-color: #409eff;
outline: none;
}
.wht-select-wrapper .select-dropdown-content .select-dropdown-empty.data-v-57f09195 {
padding: 12px;
text-align: center;
}
.wht-select-wrapper .wht-select-input.data-v-57f09195 {
width: 100%;
height: 100%;
background: transparent;
border: none;
outline: none;
padding: 0;
margin: 0;
line-height: normal;
}
.wht-select-wrapper .wht-select-input.data-v-57f09195::-webkit-input-placeholder {
color: inherit;
line-height: normal;
}
.wht-select-wrapper .wht-select-input.data-v-57f09195::placeholder {
color: inherit;
line-height: normal;
}
@media (prefers-color-scheme: dark) {
.wht-select-wrapper .select-dropdown-content.data-v-57f09195 {
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.3);
}
.wht-select-wrapper .select-dropdown-content.data-v-57f09195::-webkit-scrollbar-thumb {
background-color: #48484a;
}
.wht-select-wrapper .select-dropdown-content .select-dropdown-search.data-v-57f09195 {
border-bottom-color: #48484a;
}
.wht-select-wrapper .select-dropdown-content .select-dropdown-search input.data-v-57f09195 {
border-color: #48484a;
background-color: #1c1c1e;
color: #fff;
}
.wht-select-wrapper .select-dropdown-content .select-dropdown-search input.data-v-57f09195:focus {
border-color: #409eff;
}
}