消息
This commit is contained in:
122
unpackage/dist/dev/mp-weixin/TUIKit/components/TUISearch/search-input/index.js
vendored
Normal file
122
unpackage/dist/dev/mp-weixin/TUIKit/components/TUISearch/search-input/index.js
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
require("../../../adapter-vue.js");
|
||||
const common_assets = require("../../../../common/assets.js");
|
||||
const TUIKit_utils_env = require("../../../utils/env.js");
|
||||
if (!Math) {
|
||||
Icon();
|
||||
}
|
||||
const Icon = () => "../../common/Icon.js";
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
__name: "index",
|
||||
props: {
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: () => common_vendor.Wt.t("TUISearch.搜索")
|
||||
},
|
||||
searchType: {
|
||||
type: String,
|
||||
default: "global",
|
||||
// "global" / "conversation"
|
||||
validator(value) {
|
||||
return ["global", "conversation"].includes(value);
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(__props) {
|
||||
const props = __props;
|
||||
const searchValueModel = common_vendor.ref("");
|
||||
const currentSearchInputValue = common_vendor.ref("");
|
||||
const searchingStatus = common_vendor.ref(false);
|
||||
function onCurrentSearchInputValueChange(obj) {
|
||||
if ((obj == null ? void 0 : obj.searchType) === (props == null ? void 0 : props.searchType)) {
|
||||
currentSearchInputValue.value = obj == null ? void 0 : obj.value;
|
||||
searchValueModel.value = obj == null ? void 0 : obj.value;
|
||||
}
|
||||
}
|
||||
function onCurrentSearchingStatusChange(obj) {
|
||||
if ((obj == null ? void 0 : obj.searchType) === (props == null ? void 0 : props.searchType)) {
|
||||
searchingStatus.value = obj == null ? void 0 : obj.isSearching;
|
||||
}
|
||||
}
|
||||
common_vendor.onMounted(() => {
|
||||
common_vendor.Jt.watch(common_vendor.o.SEARCH, {
|
||||
currentSearchInputValue: onCurrentSearchInputValueChange,
|
||||
currentSearchingStatus: onCurrentSearchingStatusChange
|
||||
});
|
||||
});
|
||||
common_vendor.onUnmounted(() => {
|
||||
common_vendor.Jt.unwatch(common_vendor.o.SEARCH, {
|
||||
currentSearchInputValue: onCurrentSearchInputValueChange,
|
||||
currentSearchingStatus: onCurrentSearchingStatusChange
|
||||
});
|
||||
});
|
||||
const search = () => {
|
||||
if (searchValueModel.value === currentSearchInputValue.value) {
|
||||
return;
|
||||
}
|
||||
common_vendor.Jt.update(common_vendor.o.SEARCH, "currentSearchInputValue", {
|
||||
value: searchValueModel.value,
|
||||
searchType: props.searchType
|
||||
});
|
||||
};
|
||||
const endSearching = () => {
|
||||
searchingStatus.value = false;
|
||||
common_vendor.Jt.update(common_vendor.o.SEARCH, "currentSearchingStatus", {
|
||||
isSearching: false,
|
||||
searchType: props.searchType
|
||||
});
|
||||
common_vendor.Jt.update(common_vendor.o.SEARCH, "currentSearchInputValue", {
|
||||
value: "",
|
||||
searchType: props.searchType
|
||||
});
|
||||
};
|
||||
const onSearchInputClick = () => {
|
||||
common_vendor.Jt.update(common_vendor.o.SEARCH, "currentSearchingStatus", {
|
||||
isSearching: true,
|
||||
searchType: props.searchType
|
||||
});
|
||||
};
|
||||
const onBlur = () => {
|
||||
var _a, _b;
|
||||
(_b = (_a = common_vendor.i) == null ? void 0 : _a.hideKeyboard) == null ? void 0 : _b.call(_a);
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.p({
|
||||
file: common_vendor.unref(common_assets.searchIcon),
|
||||
width: "14px",
|
||||
height: "14px"
|
||||
}),
|
||||
b: props.placeholder,
|
||||
c: common_vendor.o$1(onBlur),
|
||||
d: common_vendor.o$1(search),
|
||||
e: common_vendor.o$1(search),
|
||||
f: common_vendor.o$1(onSearchInputClick),
|
||||
g: common_vendor.unref(searchValueModel),
|
||||
h: common_vendor.o$1(($event) => common_vendor.isRef(searchValueModel) ? searchValueModel.value = $event.detail.value : null),
|
||||
i: common_vendor.unref(searchingStatus)
|
||||
}, common_vendor.unref(searchingStatus) ? {
|
||||
j: common_vendor.p({
|
||||
file: common_vendor.unref(common_assets.closeIcon),
|
||||
width: "14px",
|
||||
height: "14px"
|
||||
}),
|
||||
k: common_vendor.o$1(endSearching)
|
||||
} : {}, {
|
||||
l: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "tui-search-input-h5"),
|
||||
m: !common_vendor.unref(TUIKit_utils_env.isPC) && common_vendor.unref(searchingStatus) && props.searchType === "global"
|
||||
}, !common_vendor.unref(TUIKit_utils_env.isPC) && common_vendor.unref(searchingStatus) && props.searchType === "global" ? {
|
||||
n: common_vendor.t(common_vendor.unref(common_vendor.Wt).t("TUISearch.取消")),
|
||||
o: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "tui-search-input-h5-cancel"),
|
||||
p: common_vendor.o$1(endSearching)
|
||||
} : {}, {
|
||||
q: common_vendor.n(!common_vendor.unref(TUIKit_utils_env.isPC) && "tui-search-input-container-h5"),
|
||||
r: common_vendor.n(props.searchType === "global" ? "tui-search-input-container-global" : "tui-search-input-container-conversation")
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-9c7789a6"]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/TUIKit/components/TUISearch/search-input/index.js.map
|
||||
Reference in New Issue
Block a user