@whitesev/pops 2.3.8 → 2.4.1
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/dist/index.amd.js +210 -99
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +210 -99
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +210 -99
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +210 -99
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +210 -99
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +210 -99
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +16 -9
- package/dist/types/src/components/searchSuggestion/config.d.ts +1 -1
- package/dist/types/src/components/searchSuggestion/index.d.ts +45 -23
- package/dist/types/src/components/searchSuggestion/types/index.d.ts +125 -37
- package/dist/types/src/utils/PopsDOMUtils.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.system.js
CHANGED
|
@@ -2529,6 +2529,36 @@ System.register('pops', [], (function (exports) {
|
|
|
2529
2529
|
transformTop: transform_top,
|
|
2530
2530
|
};
|
|
2531
2531
|
}
|
|
2532
|
+
/**
|
|
2533
|
+
* 监input、textarea的输入框值改变的事件
|
|
2534
|
+
*/
|
|
2535
|
+
onInput($el, callback, option) {
|
|
2536
|
+
let isComposite = false;
|
|
2537
|
+
let __callback = async (event) => {
|
|
2538
|
+
if (isComposite)
|
|
2539
|
+
return;
|
|
2540
|
+
await callback(event);
|
|
2541
|
+
};
|
|
2542
|
+
let __composition_start_callback = () => {
|
|
2543
|
+
isComposite = true;
|
|
2544
|
+
};
|
|
2545
|
+
let __composition_end_callback = () => {
|
|
2546
|
+
isComposite = false;
|
|
2547
|
+
this.trigger($el, "input", {
|
|
2548
|
+
isComposite,
|
|
2549
|
+
});
|
|
2550
|
+
};
|
|
2551
|
+
this.on($el, "input", __callback, option);
|
|
2552
|
+
this.on($el, "compositionstart", __composition_start_callback, option);
|
|
2553
|
+
this.on($el, "compositionend", __composition_end_callback, option);
|
|
2554
|
+
return {
|
|
2555
|
+
off: () => {
|
|
2556
|
+
this.off($el, "input", __callback, option);
|
|
2557
|
+
this.off($el, "compositionstart", __composition_start_callback, option);
|
|
2558
|
+
this.off($el, "compositionend", __composition_end_callback, option);
|
|
2559
|
+
},
|
|
2560
|
+
};
|
|
2561
|
+
}
|
|
2532
2562
|
}
|
|
2533
2563
|
const popsDOMUtils = new PopsDOMUtils();
|
|
2534
2564
|
|
|
@@ -10894,7 +10924,22 @@ System.register('pops', [], (function (exports) {
|
|
|
10894
10924
|
for (let index = 0; index < 10; index++) {
|
|
10895
10925
|
data.push({
|
|
10896
10926
|
value: `测试${index}`,
|
|
10897
|
-
|
|
10927
|
+
enableDeleteButton: true,
|
|
10928
|
+
deleteButtonClickCallback(event, $dataItem, dataItem, config) {
|
|
10929
|
+
console.log("删除当前项", [event, $dataItem, dataItem, config]);
|
|
10930
|
+
return true;
|
|
10931
|
+
},
|
|
10932
|
+
itemView(dateItem, $parent) {
|
|
10933
|
+
return `测试${index}-html`;
|
|
10934
|
+
},
|
|
10935
|
+
clickCallback(event, $dataItem, dataItem, config) {
|
|
10936
|
+
console.log("item项的点击回调", [event, $dataItem, data, config]);
|
|
10937
|
+
// config.inputTarget!.value = dataItem.value;
|
|
10938
|
+
return index % 2 === 0 ? true : false;
|
|
10939
|
+
},
|
|
10940
|
+
selectCallback(event, $dataItem, dataItem, config) {
|
|
10941
|
+
console.log("item项的选中回调", [event, $dataItem, data, config]);
|
|
10942
|
+
},
|
|
10898
10943
|
});
|
|
10899
10944
|
}
|
|
10900
10945
|
return {
|
|
@@ -10904,14 +10949,6 @@ System.register('pops', [], (function (exports) {
|
|
|
10904
10949
|
inputTarget: null,
|
|
10905
10950
|
selfDocument: document,
|
|
10906
10951
|
data: data,
|
|
10907
|
-
deleteIcon: {
|
|
10908
|
-
enable: true,
|
|
10909
|
-
callback(event, liElement, dataItem) {
|
|
10910
|
-
console.log("删除当前项", [event, liElement, dataItem]);
|
|
10911
|
-
data.splice(data.indexOf(dataItem), 1);
|
|
10912
|
-
liElement.remove();
|
|
10913
|
-
},
|
|
10914
|
-
},
|
|
10915
10952
|
useShadowRoot: true,
|
|
10916
10953
|
className: "",
|
|
10917
10954
|
isAbsolute: true,
|
|
@@ -10929,20 +10966,10 @@ System.register('pops', [], (function (exports) {
|
|
|
10929
10966
|
toSearhNotResultHTML: '<li data-none="true">暂无其它数据</li>',
|
|
10930
10967
|
toHideWithNotResult: false,
|
|
10931
10968
|
followPosition: "target",
|
|
10932
|
-
|
|
10933
|
-
return item.text ?? item;
|
|
10934
|
-
},
|
|
10935
|
-
async getData(value, data) {
|
|
10969
|
+
async inputTargetChangeRefreshShowDataCallback(value, data) {
|
|
10936
10970
|
console.log("当前输入框的值是:", value);
|
|
10937
10971
|
return data.filter((it) => it.value.includes(value));
|
|
10938
10972
|
},
|
|
10939
|
-
itemClickCallBack(event, liElement, data) {
|
|
10940
|
-
console.log("item项的点击回调", [event, liElement, data]);
|
|
10941
|
-
this.inputTarget.value = data.value;
|
|
10942
|
-
},
|
|
10943
|
-
selectCallBack(event, liElement, data) {
|
|
10944
|
-
console.log("item项的选中回调", [event, liElement, data]);
|
|
10945
|
-
},
|
|
10946
10973
|
style: "",
|
|
10947
10974
|
};
|
|
10948
10975
|
};
|
|
@@ -11002,33 +11029,49 @@ System.register('pops', [], (function (exports) {
|
|
|
11002
11029
|
/** 动态更新CSS */
|
|
11003
11030
|
$dynamicCSS: null,
|
|
11004
11031
|
},
|
|
11032
|
+
$evt: {
|
|
11033
|
+
offInputChangeEvtHandler: [],
|
|
11034
|
+
},
|
|
11005
11035
|
$data: {
|
|
11006
11036
|
/** 是否结果为空 */
|
|
11007
11037
|
isEmpty: true,
|
|
11008
11038
|
},
|
|
11009
|
-
/** 初始化元素变量 */
|
|
11010
|
-
initEl() {
|
|
11011
|
-
this.$el.root = SearchSuggestion.createSearchSelectElement();
|
|
11012
|
-
this.$el.$dynamicCSS = this.$el.root.querySelector("style[data-dynamic]");
|
|
11013
|
-
this.$el.$hintULContainer = SearchSuggestion.$el.root.querySelector("ul");
|
|
11014
|
-
},
|
|
11015
11039
|
/**
|
|
11016
11040
|
* 初始化
|
|
11041
|
+
* @param parentElement 父元素
|
|
11017
11042
|
*/
|
|
11018
11043
|
init(parentElement = document.body || document.documentElement) {
|
|
11019
|
-
|
|
11020
|
-
SearchSuggestion.update(
|
|
11044
|
+
SearchSuggestion.initEl();
|
|
11045
|
+
SearchSuggestion.update(SearchSuggestion.getData());
|
|
11021
11046
|
SearchSuggestion.updateStyleSheet();
|
|
11022
11047
|
SearchSuggestion.hide();
|
|
11023
11048
|
$shadowRoot.appendChild(SearchSuggestion.$el.root);
|
|
11024
11049
|
parentElement.appendChild($shadowContainer);
|
|
11025
11050
|
},
|
|
11051
|
+
/**
|
|
11052
|
+
* 初始化元素变量
|
|
11053
|
+
*/
|
|
11054
|
+
initEl() {
|
|
11055
|
+
SearchSuggestion.$el.root = SearchSuggestion.createSearchSelectElement();
|
|
11056
|
+
Reflect.set(SearchSuggestion.$el.root, "data-SearchSuggestion", SearchSuggestion);
|
|
11057
|
+
SearchSuggestion.$el.$dynamicCSS =
|
|
11058
|
+
SearchSuggestion.$el.root.querySelector("style[data-dynamic]");
|
|
11059
|
+
SearchSuggestion.$el.$hintULContainer =
|
|
11060
|
+
SearchSuggestion.$el.root.querySelector("ul");
|
|
11061
|
+
},
|
|
11026
11062
|
/**
|
|
11027
11063
|
* 获取数据
|
|
11028
11064
|
*/
|
|
11029
11065
|
getData() {
|
|
11030
11066
|
return typeof config.data === "function" ? config.data() : config.data;
|
|
11031
11067
|
},
|
|
11068
|
+
/**
|
|
11069
|
+
* 更新数据
|
|
11070
|
+
* @param data 数据
|
|
11071
|
+
*/
|
|
11072
|
+
setData(data) {
|
|
11073
|
+
config.data = data;
|
|
11074
|
+
},
|
|
11032
11075
|
/**
|
|
11033
11076
|
* 获取显示出搜索建议框的html
|
|
11034
11077
|
*/
|
|
@@ -11111,7 +11154,7 @@ System.register('pops', [], (function (exports) {
|
|
|
11111
11154
|
}
|
|
11112
11155
|
</style>
|
|
11113
11156
|
<style type="text/css" data-dynamic="true">
|
|
11114
|
-
${
|
|
11157
|
+
${SearchSuggestion.getDynamicCSS()}
|
|
11115
11158
|
</style>
|
|
11116
11159
|
<style>
|
|
11117
11160
|
.el-zoom-in-top-animation{
|
|
@@ -11153,7 +11196,9 @@ System.register('pops', [], (function (exports) {
|
|
|
11153
11196
|
}
|
|
11154
11197
|
return $el;
|
|
11155
11198
|
},
|
|
11156
|
-
/**
|
|
11199
|
+
/**
|
|
11200
|
+
* 动态获取CSS
|
|
11201
|
+
*/
|
|
11157
11202
|
getDynamicCSS() {
|
|
11158
11203
|
return /*css*/ `
|
|
11159
11204
|
.pops-${popsType}-search-suggestion{
|
|
@@ -11218,53 +11263,82 @@ System.register('pops', [], (function (exports) {
|
|
|
11218
11263
|
}
|
|
11219
11264
|
`;
|
|
11220
11265
|
},
|
|
11266
|
+
/**
|
|
11267
|
+
* 获取data-value值
|
|
11268
|
+
* @param data 数据项
|
|
11269
|
+
*/
|
|
11270
|
+
getItemDataValue(data) {
|
|
11271
|
+
return data;
|
|
11272
|
+
},
|
|
11221
11273
|
/**
|
|
11222
11274
|
* 获取显示出搜索建议框的每一项的html
|
|
11223
|
-
* @param
|
|
11224
|
-
* @param
|
|
11275
|
+
* @param dataItem 当前项的值
|
|
11276
|
+
* @param dateItemIndex 当前项的下标
|
|
11225
11277
|
*/
|
|
11226
|
-
createSearchItemLiElement(
|
|
11278
|
+
createSearchItemLiElement(dataItem, dateItemIndex) {
|
|
11279
|
+
const dataValue = SearchSuggestion.getItemDataValue(dataItem);
|
|
11227
11280
|
let $li = popsDOMUtils.createElement("li", {
|
|
11228
11281
|
className: `pops-${popsType}-search-suggestion-hint-item`,
|
|
11229
|
-
"data-index":
|
|
11230
|
-
"data-value":
|
|
11231
|
-
innerHTML: `${config.getItemHTML(data)}${config.deleteIcon.enable ? SearchSuggestion.getDeleteIconHTML() : ""}`,
|
|
11282
|
+
"data-index": dateItemIndex,
|
|
11283
|
+
"data-value": dataValue,
|
|
11232
11284
|
});
|
|
11285
|
+
Reflect.set($li, "data-index", dateItemIndex);
|
|
11286
|
+
Reflect.set($li, "data-value", dataValue);
|
|
11287
|
+
// 项内容
|
|
11288
|
+
let $itemInner = dataItem.itemView(dataItem, $li, config);
|
|
11289
|
+
if (typeof $itemInner === "string") {
|
|
11290
|
+
PopsSafeUtils.setSafeHTML($li, $itemInner);
|
|
11291
|
+
}
|
|
11292
|
+
else {
|
|
11293
|
+
popsDOMUtils.append($li, $itemInner);
|
|
11294
|
+
}
|
|
11295
|
+
// 删除按钮
|
|
11296
|
+
const enableDeleteButton = dataItem.enableDeleteButton;
|
|
11297
|
+
if (typeof enableDeleteButton === "boolean" && enableDeleteButton) {
|
|
11298
|
+
let $deleteIcon = SearchSuggestion.createItemDeleteIcon();
|
|
11299
|
+
popsDOMUtils.append($li, $deleteIcon);
|
|
11300
|
+
}
|
|
11233
11301
|
popsDOMUtils.addClassName($li, PopsCommonCSSClassName.flexCenter);
|
|
11234
11302
|
popsDOMUtils.addClassName($li, PopsCommonCSSClassName.flexYCenter);
|
|
11235
11303
|
return $li;
|
|
11236
11304
|
},
|
|
11237
|
-
/**
|
|
11238
|
-
* 获取data-value值
|
|
11239
|
-
* @param data
|
|
11240
|
-
*/
|
|
11241
|
-
getItemDataValue(data) {
|
|
11242
|
-
return data;
|
|
11243
|
-
},
|
|
11244
11305
|
/**
|
|
11245
11306
|
* 设置搜索建议框每一项的点击事件
|
|
11246
|
-
* @param $searchItem
|
|
11307
|
+
* @param $searchItem 当前项的元素
|
|
11247
11308
|
*/
|
|
11248
11309
|
setSearchItemClickEvent($searchItem) {
|
|
11249
|
-
popsDOMUtils.on($searchItem, "click", (event) => {
|
|
11310
|
+
popsDOMUtils.on($searchItem, "click", async (event) => {
|
|
11250
11311
|
popsDOMUtils.preventEvent(event);
|
|
11251
11312
|
let $click = event.target;
|
|
11252
|
-
|
|
11313
|
+
const data = SearchSuggestion.getData();
|
|
11314
|
+
const dataItem = Reflect.get($searchItem, "data-value");
|
|
11253
11315
|
let isDelete = Boolean($click.closest(`.pops-${popsType}-delete-icon`));
|
|
11254
11316
|
if (isDelete) {
|
|
11255
11317
|
// 删除
|
|
11256
|
-
if (typeof
|
|
11257
|
-
|
|
11318
|
+
if (typeof dataItem.deleteButtonClickCallback === "function") {
|
|
11319
|
+
let result = await dataItem.deleteButtonClickCallback(event, $searchItem, dataItem, config);
|
|
11320
|
+
if (typeof result === "boolean" && result) {
|
|
11321
|
+
data.splice(data.indexOf(dataItem), 1);
|
|
11322
|
+
$searchItem.remove();
|
|
11323
|
+
}
|
|
11258
11324
|
}
|
|
11259
|
-
if (!
|
|
11325
|
+
if (!SearchSuggestion.$el.$hintULContainer.children.length) {
|
|
11260
11326
|
/* 全删完了 */
|
|
11261
|
-
|
|
11327
|
+
SearchSuggestion.clear();
|
|
11262
11328
|
}
|
|
11263
11329
|
SearchSuggestion.updateStyleSheet();
|
|
11264
11330
|
}
|
|
11265
11331
|
else {
|
|
11266
11332
|
// 点击选择项
|
|
11267
|
-
|
|
11333
|
+
if (typeof dataItem.clickCallback === "function") {
|
|
11334
|
+
let result = await dataItem.clickCallback(event, $searchItem, dataItem, config);
|
|
11335
|
+
if (typeof result === "boolean" && result) {
|
|
11336
|
+
if (config.inputTarget instanceof HTMLInputElement ||
|
|
11337
|
+
config.inputTarget instanceof HTMLTextAreaElement) {
|
|
11338
|
+
config.inputTarget.value = String(dataItem.value);
|
|
11339
|
+
}
|
|
11340
|
+
}
|
|
11341
|
+
}
|
|
11268
11342
|
}
|
|
11269
11343
|
}, {
|
|
11270
11344
|
capture: true,
|
|
@@ -11303,11 +11377,13 @@ System.register('pops', [], (function (exports) {
|
|
|
11303
11377
|
/* 禁用输入框自动提示 */
|
|
11304
11378
|
config.inputTarget.setAttribute("autocomplete", "off");
|
|
11305
11379
|
/* 内容改变事件 */
|
|
11306
|
-
popsDOMUtils.
|
|
11307
|
-
|
|
11308
|
-
|
|
11380
|
+
const listenerHandler = popsDOMUtils.onInput(config.inputTarget, async (event) => {
|
|
11381
|
+
const data = SearchSuggestion.getData();
|
|
11382
|
+
let queryDataResult = await config.inputTargetChangeRefreshShowDataCallback(config.inputTarget.value, data, config);
|
|
11383
|
+
SearchSuggestion.update(queryDataResult);
|
|
11309
11384
|
SearchSuggestion.updateStyleSheet();
|
|
11310
11385
|
}, option);
|
|
11386
|
+
SearchSuggestion.$evt.offInputChangeEvtHandler.push(listenerHandler.off);
|
|
11311
11387
|
},
|
|
11312
11388
|
/**
|
|
11313
11389
|
* 移除输入框内容改变的监听
|
|
@@ -11315,7 +11391,12 @@ System.register('pops', [], (function (exports) {
|
|
|
11315
11391
|
removeInputChangeEvent(option = {
|
|
11316
11392
|
capture: true,
|
|
11317
11393
|
}) {
|
|
11318
|
-
|
|
11394
|
+
for (let index = 0; index < SearchSuggestion.$evt.offInputChangeEvtHandler.length; index++) {
|
|
11395
|
+
const handler = SearchSuggestion.$evt.offInputChangeEvtHandler[index];
|
|
11396
|
+
handler();
|
|
11397
|
+
SearchSuggestion.$evt.offInputChangeEvtHandler.splice(index, 1);
|
|
11398
|
+
index--;
|
|
11399
|
+
}
|
|
11319
11400
|
},
|
|
11320
11401
|
/**
|
|
11321
11402
|
* 显示搜索建议框的事件
|
|
@@ -11441,23 +11522,24 @@ System.register('pops', [], (function (exports) {
|
|
|
11441
11522
|
/**
|
|
11442
11523
|
* 获取删除按钮的html
|
|
11443
11524
|
*/
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11450
|
-
|
|
11525
|
+
createItemDeleteIcon(size = 16, fill = "#bababa") {
|
|
11526
|
+
let $svg = popsDOMUtils.parseTextToDOM(/*html*/ `
|
|
11527
|
+
<svg class="pops-${popsType}-delete-icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" fill="${fill}">
|
|
11528
|
+
<path d="M512 883.2A371.2 371.2 0 1 0 140.8 512 371.2 371.2 0 0 0 512 883.2z m0 64a435.2 435.2 0 1 1 435.2-435.2 435.2 435.2 0 0 1-435.2 435.2z"></path>
|
|
11529
|
+
<path d="M557.056 512l122.368 122.368a31.744 31.744 0 1 1-45.056 45.056L512 557.056l-122.368 122.368a31.744 31.744 0 1 1-45.056-45.056L466.944 512 344.576 389.632a31.744 31.744 0 1 1 45.056-45.056L512 466.944l122.368-122.368a31.744 31.744 0 1 1 45.056 45.056z"></path>
|
|
11530
|
+
</svg>
|
|
11531
|
+
`);
|
|
11532
|
+
return $svg;
|
|
11451
11533
|
},
|
|
11452
11534
|
/**
|
|
11453
11535
|
* 设置当前正在搜索中的提示
|
|
11454
11536
|
*/
|
|
11455
11537
|
setPromptsInSearch() {
|
|
11456
|
-
let
|
|
11538
|
+
let $isSearching = popsDOMUtils.createElement("li", {
|
|
11457
11539
|
className: `pops-${popsType}-search-suggestion-hint-searching-item`,
|
|
11458
11540
|
innerHTML: config.searchingTip,
|
|
11459
11541
|
});
|
|
11460
|
-
SearchSuggestion
|
|
11542
|
+
SearchSuggestion.addItem($isSearching);
|
|
11461
11543
|
},
|
|
11462
11544
|
/**
|
|
11463
11545
|
* 移除正在搜索中的提示
|
|
@@ -11467,17 +11549,13 @@ System.register('pops', [], (function (exports) {
|
|
|
11467
11549
|
.querySelector(`li.pops-${popsType}-search-suggestion-hint-searching-item`)
|
|
11468
11550
|
?.remove();
|
|
11469
11551
|
},
|
|
11470
|
-
/**
|
|
11471
|
-
* 清空所有的搜索结果
|
|
11472
|
-
*/
|
|
11473
|
-
clearAllSearchItemLi() {
|
|
11474
|
-
PopsSafeUtils.setSafeHTML(SearchSuggestion.$el.$hintULContainer, "");
|
|
11475
|
-
},
|
|
11476
11552
|
/**
|
|
11477
11553
|
* 更新搜索建议框的位置(top、left)
|
|
11478
11554
|
* 因为目标元素可能是动态隐藏的
|
|
11555
|
+
* @param target 目标元素
|
|
11556
|
+
* @param checkPositonAgain 是否在更新位置信息后检测更新位置信息,默认true
|
|
11479
11557
|
*/
|
|
11480
|
-
changeHintULElementPosition(target = config.target ?? config.inputTarget) {
|
|
11558
|
+
changeHintULElementPosition(target = config.target ?? config.inputTarget, checkPositonAgain = true) {
|
|
11481
11559
|
let targetRect = null;
|
|
11482
11560
|
if (config.followPosition === "inputCursor") {
|
|
11483
11561
|
targetRect = popsDOMUtils.getTextBoundingRect(config.inputTarget, config.inputTarget.selectionStart || 0, config.inputTarget.selectionEnd || 0, false);
|
|
@@ -11541,10 +11619,19 @@ System.register('pops', [], (function (exports) {
|
|
|
11541
11619
|
left = left + documentWidth - hintUIWidth;
|
|
11542
11620
|
}
|
|
11543
11621
|
SearchSuggestion.$el.root.style.left = left + "px";
|
|
11622
|
+
// 如果更新前在下面的话且高度超出了屏幕
|
|
11623
|
+
// 这时候会有滚动条,会造成位置偏移
|
|
11624
|
+
// 更新后的位置却在上面,这时候的位置信息不对齐
|
|
11625
|
+
// 需重新更新位置
|
|
11626
|
+
// 此情况一般是config.position === "auto"
|
|
11627
|
+
if (checkPositonAgain) {
|
|
11628
|
+
SearchSuggestion.changeHintULElementPosition(target, !checkPositonAgain);
|
|
11629
|
+
}
|
|
11544
11630
|
},
|
|
11545
11631
|
/**
|
|
11546
11632
|
* 更新搜索建议框的width
|
|
11547
11633
|
* 因为目标元素可能是动态隐藏的
|
|
11634
|
+
* @param target 目标元素
|
|
11548
11635
|
*/
|
|
11549
11636
|
changeHintULElementWidth(target = config.target ?? config.inputTarget) {
|
|
11550
11637
|
let targetRect = target.getBoundingClientRect();
|
|
@@ -11559,11 +11646,15 @@ System.register('pops', [], (function (exports) {
|
|
|
11559
11646
|
* 动态更新CSS
|
|
11560
11647
|
*/
|
|
11561
11648
|
updateDynamicCSS() {
|
|
11562
|
-
let cssText =
|
|
11563
|
-
PopsSafeUtils.setSafeHTML(
|
|
11649
|
+
let cssText = SearchSuggestion.getDynamicCSS();
|
|
11650
|
+
PopsSafeUtils.setSafeHTML(SearchSuggestion.$el.$dynamicCSS, cssText);
|
|
11564
11651
|
},
|
|
11565
11652
|
/**
|
|
11566
11653
|
* 数据项的数量改变时调用
|
|
11654
|
+
*
|
|
11655
|
+
* - 更新css
|
|
11656
|
+
* - 更新建议框的宽度
|
|
11657
|
+
* - 更新建议框的位置
|
|
11567
11658
|
*/
|
|
11568
11659
|
updateStyleSheet() {
|
|
11569
11660
|
// 更新z-index
|
|
@@ -11573,29 +11664,38 @@ System.register('pops', [], (function (exports) {
|
|
|
11573
11664
|
// 更新位置
|
|
11574
11665
|
SearchSuggestion.changeHintULElementPosition();
|
|
11575
11666
|
},
|
|
11667
|
+
/**
|
|
11668
|
+
* 添加搜索结果元素
|
|
11669
|
+
* @param $item 项元素
|
|
11670
|
+
*/
|
|
11671
|
+
addItem($item) {
|
|
11672
|
+
SearchSuggestion.$el.$hintULContainer.appendChild($item);
|
|
11673
|
+
},
|
|
11576
11674
|
/**
|
|
11577
11675
|
* 更新页面显示的搜索结果
|
|
11578
|
-
* @param
|
|
11676
|
+
* @param updateData
|
|
11579
11677
|
*/
|
|
11580
|
-
update(
|
|
11581
|
-
if (!Array.isArray(
|
|
11678
|
+
update(updateData = []) {
|
|
11679
|
+
if (!Array.isArray(updateData)) {
|
|
11582
11680
|
throw new TypeError("传入的数据不是数组");
|
|
11583
11681
|
}
|
|
11584
|
-
|
|
11682
|
+
const data = updateData;
|
|
11585
11683
|
/* 清空已有的搜索结果 */
|
|
11586
|
-
if (
|
|
11684
|
+
if (data.length) {
|
|
11587
11685
|
SearchSuggestion.$data.isEmpty = false;
|
|
11588
11686
|
if (config.toHideWithNotResult) {
|
|
11589
11687
|
SearchSuggestion.show();
|
|
11590
11688
|
}
|
|
11591
|
-
SearchSuggestion.
|
|
11689
|
+
SearchSuggestion.clear(true);
|
|
11592
11690
|
/* 添加进ul中 */
|
|
11593
|
-
|
|
11594
|
-
|
|
11595
|
-
SearchSuggestion.
|
|
11596
|
-
SearchSuggestion.
|
|
11597
|
-
SearchSuggestion
|
|
11691
|
+
let fragment = document.createDocumentFragment();
|
|
11692
|
+
data.forEach((item, index) => {
|
|
11693
|
+
let $item = SearchSuggestion.createSearchItemLiElement(item, index);
|
|
11694
|
+
SearchSuggestion.setSearchItemClickEvent($item);
|
|
11695
|
+
SearchSuggestion.setSearchItemSelectEvent($item);
|
|
11696
|
+
fragment.appendChild($item);
|
|
11598
11697
|
});
|
|
11698
|
+
SearchSuggestion.addItem(fragment);
|
|
11599
11699
|
}
|
|
11600
11700
|
else {
|
|
11601
11701
|
/* 清空 */
|
|
@@ -11604,13 +11704,24 @@ System.register('pops', [], (function (exports) {
|
|
|
11604
11704
|
},
|
|
11605
11705
|
/**
|
|
11606
11706
|
* 清空当前的搜索结果并显示无结果
|
|
11707
|
+
* @param [onlyClearView=false] 是否仅清空元素,默认false
|
|
11607
11708
|
*/
|
|
11608
|
-
clear() {
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11709
|
+
clear(onlyClearView = false) {
|
|
11710
|
+
PopsSafeUtils.setSafeHTML(SearchSuggestion.$el.$hintULContainer, "");
|
|
11711
|
+
if (onlyClearView) {
|
|
11712
|
+
return;
|
|
11713
|
+
}
|
|
11714
|
+
SearchSuggestion.$data.isEmpty = true;
|
|
11715
|
+
let $noResult;
|
|
11716
|
+
if (typeof config.toSearhNotResultHTML === "string") {
|
|
11717
|
+
$noResult = popsDOMUtils.parseTextToDOM(config.toSearhNotResultHTML);
|
|
11718
|
+
}
|
|
11719
|
+
else {
|
|
11720
|
+
$noResult = config.toSearhNotResultHTML();
|
|
11721
|
+
}
|
|
11722
|
+
SearchSuggestion.addItem($noResult);
|
|
11612
11723
|
if (config.toHideWithNotResult) {
|
|
11613
|
-
|
|
11724
|
+
SearchSuggestion.hide();
|
|
11614
11725
|
}
|
|
11615
11726
|
},
|
|
11616
11727
|
/**
|
|
@@ -11621,25 +11732,25 @@ System.register('pops', [], (function (exports) {
|
|
|
11621
11732
|
if (config.useFoldAnimation) {
|
|
11622
11733
|
if (!useAnimationToHide) {
|
|
11623
11734
|
// 去掉动画
|
|
11624
|
-
popsDOMUtils.removeClassName(
|
|
11735
|
+
popsDOMUtils.removeClassName(SearchSuggestion.$el.root, "el-zoom-in-top-animation");
|
|
11625
11736
|
}
|
|
11626
|
-
popsDOMUtils.addClassName(
|
|
11627
|
-
popsDOMUtils.addClassName(
|
|
11628
|
-
popsDOMUtils.removeClassName(
|
|
11737
|
+
popsDOMUtils.addClassName(SearchSuggestion.$el.root, "el-zoom-in-top-animation");
|
|
11738
|
+
popsDOMUtils.addClassName(SearchSuggestion.$el.root, "el-zoom-in-top-animation-hide");
|
|
11739
|
+
popsDOMUtils.removeClassName(SearchSuggestion.$el.root, "el-zoom-in-top-animation-show");
|
|
11629
11740
|
}
|
|
11630
11741
|
else {
|
|
11631
|
-
|
|
11742
|
+
SearchSuggestion.$el.root.style.display = "none";
|
|
11632
11743
|
}
|
|
11633
11744
|
},
|
|
11634
11745
|
/**
|
|
11635
11746
|
* 显示搜索建议框
|
|
11636
11747
|
*/
|
|
11637
11748
|
show() {
|
|
11638
|
-
|
|
11749
|
+
SearchSuggestion.$el.root.style.display = "";
|
|
11639
11750
|
if (config.useFoldAnimation) {
|
|
11640
|
-
popsDOMUtils.addClassName(
|
|
11641
|
-
popsDOMUtils.removeClassName(
|
|
11642
|
-
popsDOMUtils.addClassName(
|
|
11751
|
+
popsDOMUtils.addClassName(SearchSuggestion.$el.root, "el-zoom-in-top-animation");
|
|
11752
|
+
popsDOMUtils.removeClassName(SearchSuggestion.$el.root, "el-zoom-in-top-animation-hide");
|
|
11753
|
+
popsDOMUtils.addClassName(SearchSuggestion.$el.root, "el-zoom-in-top-animation-show");
|
|
11643
11754
|
}
|
|
11644
11755
|
},
|
|
11645
11756
|
};
|
|
@@ -11651,7 +11762,7 @@ System.register('pops', [], (function (exports) {
|
|
|
11651
11762
|
/** 配置 */
|
|
11652
11763
|
config = {
|
|
11653
11764
|
/** 版本号 */
|
|
11654
|
-
version: "2025.9.
|
|
11765
|
+
version: "2025.9.4",
|
|
11655
11766
|
cssText: PopsCSS,
|
|
11656
11767
|
/** icon图标的svg代码 */
|
|
11657
11768
|
iconSVG: PopsIcon.$data,
|