bkui-vue 0.0.1-beta.181 → 0.0.1-beta.182
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.cjs.js +33 -33
- package/dist/index.esm.js +180 -16
- package/dist/index.umd.js +33 -33
- package/dist/style.css +1 -1
- package/dist/style.variable.css +1 -1
- package/lib/cascader/cascader-panel.d.ts +38 -4
- package/lib/cascader/cascader.css +23 -0
- package/lib/cascader/cascader.d.ts +19 -5
- package/lib/cascader/cascader.less +26 -0
- package/lib/cascader/cascader.variable.css +23 -0
- package/lib/cascader/index.d.ts +93 -17
- package/lib/cascader/index.js +1 -1
- package/lib/cascader/interface.d.ts +4 -0
- package/lib/cascader/node.d.ts +7 -1
- package/lib/cascader/store.d.ts +5 -1
- package/lib/date-picker/index.js +1 -1
- package/lib/shared/index.d.ts +1 -1
- package/lib/shared/index.js +1 -1
- package/lib/shared/utils.d.ts +1 -0
- package/lib/tag-input/index.d.ts +4 -4
- package/lib/tag-input/tag-input.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -7354,6 +7354,7 @@ const observerResize$1 = (root, callbackFn, delay = 60, immediate = false) => {
|
|
7354
7354
|
}
|
7355
7355
|
};
|
7356
7356
|
};
|
7357
|
+
const capitalize = (str) => str[0].toUpperCase() + str.slice(1);
|
7357
7358
|
class BkMaskManager {
|
7358
7359
|
constructor(config) {
|
7359
7360
|
this.multiInstance = false;
|
@@ -8017,6 +8018,9 @@ function arrayEqual(arr1 = [], arr2 = []) {
|
|
8017
8018
|
return false;
|
8018
8019
|
}
|
8019
8020
|
for (let i2 = 0; i2 < arr1.length; i2++) {
|
8021
|
+
if (Array.isArray(arr1[i2])) {
|
8022
|
+
return arrayEqual(arr1[i2], arr2[i2]);
|
8023
|
+
}
|
8020
8024
|
if (arr1[i2] !== arr2[i2]) {
|
8021
8025
|
return false;
|
8022
8026
|
}
|
@@ -23309,7 +23313,6 @@ const mergeDateHMS = (date, ...hms) => {
|
|
23309
23313
|
newDate.setSeconds(hms[2]);
|
23310
23314
|
return newDate;
|
23311
23315
|
};
|
23312
|
-
const capitalize = (str) => str[0].toUpperCase() + str.slice(1);
|
23313
23316
|
const dateTableProps = {
|
23314
23317
|
tableDate: {
|
23315
23318
|
type: Date,
|
@@ -27974,7 +27977,11 @@ var CascaderPanel = defineComponent({
|
|
27974
27977
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).def("auto"),
|
27975
27978
|
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).def(216),
|
27976
27979
|
store: PropTypes.object.def({}),
|
27977
|
-
|
27980
|
+
separator: PropTypes.string.def(""),
|
27981
|
+
suggestions: PropTypes.arrayOf(A()),
|
27982
|
+
isFiltering: PropTypes.bool.def(false),
|
27983
|
+
searchKey: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).def(""),
|
27984
|
+
modelValue: PropTypes.arrayOf(PropTypes.oneOfType([q(), String, Number]))
|
27978
27985
|
},
|
27979
27986
|
emits: ["update:modelValue"],
|
27980
27987
|
setup(props2, {
|
@@ -28008,6 +28015,9 @@ var CascaderPanel = defineComponent({
|
|
28008
28015
|
checkValue.value = value;
|
28009
28016
|
};
|
28010
28017
|
const nodeCheckHandler = (node) => {
|
28018
|
+
if (node.isDisabled) {
|
28019
|
+
return;
|
28020
|
+
}
|
28011
28021
|
if (node.config.multiple) {
|
28012
28022
|
checkValue.value = store.getCheckedNodes().map((node2) => node2.path);
|
28013
28023
|
} else {
|
@@ -28057,6 +28067,23 @@ var CascaderPanel = defineComponent({
|
|
28057
28067
|
};
|
28058
28068
|
return events;
|
28059
28069
|
};
|
28070
|
+
const searchPanelEvents = (node) => {
|
28071
|
+
const {
|
28072
|
+
multiple
|
28073
|
+
} = node.config;
|
28074
|
+
const events = {
|
28075
|
+
onClick: (e) => {
|
28076
|
+
if (multiple) {
|
28077
|
+
e.stopPropagation();
|
28078
|
+
checkNode(node, !node.checked);
|
28079
|
+
return;
|
28080
|
+
}
|
28081
|
+
nodeExpandHandler(node);
|
28082
|
+
node.isLeaf && !multiple && nodeCheckHandler(node);
|
28083
|
+
}
|
28084
|
+
};
|
28085
|
+
return events;
|
28086
|
+
};
|
28060
28087
|
const isNodeInPath = (node) => {
|
28061
28088
|
const currentLevel = activePath.value[node.level - 1] || {};
|
28062
28089
|
return currentLevel.id === node.id;
|
@@ -28066,12 +28093,12 @@ var CascaderPanel = defineComponent({
|
|
28066
28093
|
multiple
|
28067
28094
|
} = node.config;
|
28068
28095
|
if (multiple) {
|
28069
|
-
return
|
28096
|
+
return checkValue2.some((val) => arrayEqual(val, node.path));
|
28070
28097
|
}
|
28071
28098
|
return arrayEqual(checkValue2, node.path);
|
28072
28099
|
};
|
28073
28100
|
const checkNode = (node, value) => {
|
28074
|
-
node.setNodeCheck(value);
|
28101
|
+
node.setNodeCheck(value ? value : false);
|
28075
28102
|
nodeCheckHandler(node);
|
28076
28103
|
};
|
28077
28104
|
const iconRender = (node) => node.loading ? createVNode(spinner, {
|
@@ -28098,13 +28125,35 @@ var CascaderPanel = defineComponent({
|
|
28098
28125
|
checkNode,
|
28099
28126
|
iconRender,
|
28100
28127
|
panelWidth,
|
28101
|
-
panelHeight
|
28128
|
+
panelHeight,
|
28129
|
+
searchPanelEvents
|
28102
28130
|
};
|
28103
28131
|
},
|
28104
28132
|
render() {
|
28133
|
+
const emptyWidth = parseInt(this.panelWidth, 10) > 200 ? this.panelWidth : `${200}px`;
|
28134
|
+
const searchPanelRender = () => this.suggestions.length ? createVNode("ul", {
|
28135
|
+
"class": "bk-cascader-panel bk-scroll-y",
|
28136
|
+
"style": {
|
28137
|
+
height: this.panelHeight,
|
28138
|
+
width: this.panelWidth
|
28139
|
+
}
|
28140
|
+
}, [this.suggestions.map((node) => createVNode("li", mergeProps({
|
28141
|
+
"class": ["bk-cascader-node", {
|
28142
|
+
"is-selected": this.isNodeInPath(node)
|
28143
|
+
}, {
|
28144
|
+
"is-disabled": node.isDisabled
|
28145
|
+
}, {
|
28146
|
+
"is-checked": this.isCheckedNode(node, this.checkValue)
|
28147
|
+
}]
|
28148
|
+
}, this.searchPanelEvents(node)), [node.pathNames.join(this.separator)]))]) : createVNode("div", {
|
28149
|
+
"class": "bk-cascader-search-empty",
|
28150
|
+
"style": {
|
28151
|
+
width: emptyWidth
|
28152
|
+
}
|
28153
|
+
}, [createVNode("span", null, [createTextVNode("\u6682\u65E0\u641C\u7D22\u7ED3\u679C")])]);
|
28105
28154
|
return createVNode("div", {
|
28106
28155
|
"class": "bk-cascader-panel-wrapper"
|
28107
|
-
}, [this.menus.list.map((menu2) => createVNode("ul", {
|
28156
|
+
}, [this.isFiltering ? searchPanelRender() : this.menus.list.map((menu2) => createVNode("ul", {
|
28108
28157
|
"class": "bk-cascader-panel bk-scroll-y",
|
28109
28158
|
"style": {
|
28110
28159
|
height: this.panelHeight,
|
@@ -28118,12 +28167,13 @@ var CascaderPanel = defineComponent({
|
|
28118
28167
|
}, {
|
28119
28168
|
"is-disabled": node.isDisabled
|
28120
28169
|
}, {
|
28121
|
-
"is-checked": this.isCheckedNode(node, this.checkValue)
|
28170
|
+
"is-checked": !node.config.multiple && this.isCheckedNode(node, this.checkValue)
|
28122
28171
|
}]
|
28123
|
-
}, this.nodeEvent(node)), [node.config.multiple && createVNode(BkCheckbox, {
|
28172
|
+
}, Object.assign(this.nodeEvent(node), node.config.multiple ? {} : {})), [node.config.multiple && createVNode(BkCheckbox, {
|
28124
28173
|
"disabled": node.isDisabled,
|
28125
28174
|
"modelValue": node.checked,
|
28126
28175
|
"onUpdate:modelValue": ($event) => node.checked = $event,
|
28176
|
+
"indeterminate": node.isIndeterminate,
|
28127
28177
|
"onChange": (val) => this.checkNode(node, val)
|
28128
28178
|
}, null), (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a, {
|
28129
28179
|
node,
|
@@ -28132,6 +28182,15 @@ var CascaderPanel = defineComponent({
|
|
28132
28182
|
})]))]);
|
28133
28183
|
}
|
28134
28184
|
});
|
28185
|
+
function isNodeDisabled(node) {
|
28186
|
+
if (node.data.disabled) {
|
28187
|
+
return true;
|
28188
|
+
}
|
28189
|
+
if (node.level !== 1) {
|
28190
|
+
return isNodeDisabled(node.parent);
|
28191
|
+
}
|
28192
|
+
return node.data.disabled;
|
28193
|
+
}
|
28135
28194
|
class Node$1 {
|
28136
28195
|
constructor(node, config, parent) {
|
28137
28196
|
this.data = node;
|
@@ -28163,10 +28222,58 @@ class Node$1 {
|
|
28163
28222
|
return !(Array.isArray(this.children) && ((_a = this.children) == null ? void 0 : _a.length) !== 0);
|
28164
28223
|
}
|
28165
28224
|
get isDisabled() {
|
28166
|
-
return this
|
28225
|
+
return isNodeDisabled(this);
|
28226
|
+
}
|
28227
|
+
broadcast(event, checkStatus) {
|
28228
|
+
const handlerName = `onParent${capitalize(event)}`;
|
28229
|
+
this.children.forEach((child) => {
|
28230
|
+
var _a;
|
28231
|
+
if (child) {
|
28232
|
+
child.broadcast(event, checkStatus);
|
28233
|
+
(_a = child[handlerName]) == null ? void 0 : _a.call(child, checkStatus);
|
28234
|
+
}
|
28235
|
+
});
|
28236
|
+
}
|
28237
|
+
emit(event) {
|
28238
|
+
var _a;
|
28239
|
+
const { parent } = this;
|
28240
|
+
const handlerName = `onChild${capitalize(event)}`;
|
28241
|
+
if (parent) {
|
28242
|
+
(_a = parent[handlerName]) == null ? void 0 : _a.call(parent);
|
28243
|
+
parent.emit(event);
|
28244
|
+
}
|
28245
|
+
}
|
28246
|
+
onParentCheck(checked) {
|
28247
|
+
if (!this.isDisabled) {
|
28248
|
+
this.setCheckState(checked);
|
28249
|
+
}
|
28250
|
+
}
|
28251
|
+
onChildCheck() {
|
28252
|
+
const { children } = this;
|
28253
|
+
const validChildren = children.filter((child) => !child.isDisabled);
|
28254
|
+
const checked = validChildren.length ? validChildren.every((child) => child.checked) : false;
|
28255
|
+
this.setCheckState(checked);
|
28256
|
+
}
|
28257
|
+
setCheckState(checked) {
|
28258
|
+
const totalNum = this.children.length;
|
28259
|
+
const checkedNum = this.children.reduce((c2, p2) => {
|
28260
|
+
const tempNum = p2.isIndeterminate ? 0.5 : 0;
|
28261
|
+
const num = p2.checked ? 1 : tempNum;
|
28262
|
+
return c2 + num;
|
28263
|
+
}, 0);
|
28264
|
+
this.checked = checked;
|
28265
|
+
this.isIndeterminate = checkedNum !== totalNum && checkedNum > 0;
|
28167
28266
|
}
|
28168
28267
|
setNodeCheck(status) {
|
28169
|
-
this.checked
|
28268
|
+
if (this.checked !== status) {
|
28269
|
+
if (this.config.checkAnyLevel) {
|
28270
|
+
this.checked = status;
|
28271
|
+
return;
|
28272
|
+
}
|
28273
|
+
this.broadcast("check", status);
|
28274
|
+
this.setCheckState(status);
|
28275
|
+
this.emit("check");
|
28276
|
+
}
|
28170
28277
|
}
|
28171
28278
|
calculateNodesPath() {
|
28172
28279
|
const nodes = [this];
|
@@ -28197,6 +28304,21 @@ class Store {
|
|
28197
28304
|
getNodes() {
|
28198
28305
|
return this.nodes;
|
28199
28306
|
}
|
28307
|
+
clearChecked() {
|
28308
|
+
this.getFlattedNodes().forEach((node) => {
|
28309
|
+
node.checked = false;
|
28310
|
+
node.isIndeterminate = false;
|
28311
|
+
});
|
28312
|
+
}
|
28313
|
+
removeTag(tag2) {
|
28314
|
+
this.getFlattedNodes().find((node) => {
|
28315
|
+
if (arrayEqual(tag2, node.path)) {
|
28316
|
+
node.checked = false;
|
28317
|
+
return true;
|
28318
|
+
}
|
28319
|
+
return false;
|
28320
|
+
});
|
28321
|
+
}
|
28200
28322
|
getFlattedNodes(leafOnly = false) {
|
28201
28323
|
return flatNodes(this.nodes, leafOnly);
|
28202
28324
|
}
|
@@ -28230,7 +28352,7 @@ var Component$6 = defineComponent({
|
|
28230
28352
|
BkPopover: BkPopover2
|
28231
28353
|
},
|
28232
28354
|
props: {
|
28233
|
-
modelValue: PropTypes.
|
28355
|
+
modelValue: PropTypes.arrayOf(PropTypes.oneOfType([q(), String, Number])),
|
28234
28356
|
list: PropTypes.array.def([]),
|
28235
28357
|
placeholder: PropTypes.string.def("\u8BF7\u9009\u62E9"),
|
28236
28358
|
filterable: PropTypes.bool.def(false),
|
@@ -28272,6 +28394,9 @@ var Component$6 = defineComponent({
|
|
28272
28394
|
modelValue
|
28273
28395
|
} = toRefs(props2);
|
28274
28396
|
const cascaderPanel = ref();
|
28397
|
+
const searchKey = ref("");
|
28398
|
+
const suggestions = ref([]);
|
28399
|
+
const isFiltering = ref(false);
|
28275
28400
|
const checkedValue = computed({
|
28276
28401
|
get: () => modelValue.value,
|
28277
28402
|
set: (value) => {
|
@@ -28280,6 +28405,9 @@ var Component$6 = defineComponent({
|
|
28280
28405
|
});
|
28281
28406
|
const popover3 = ref(null);
|
28282
28407
|
const getShowText = (node) => props2.showCompleteName ? node.pathNames.join(separator2) : node.pathNames[node.pathNames.length - 1];
|
28408
|
+
const updateSearchKey = () => {
|
28409
|
+
searchKey.value = selectedText.value;
|
28410
|
+
};
|
28283
28411
|
const updateValue = (val) => {
|
28284
28412
|
var _a;
|
28285
28413
|
if (multiple) {
|
@@ -28298,9 +28426,12 @@ var Component$6 = defineComponent({
|
|
28298
28426
|
return;
|
28299
28427
|
selectedText.value = getShowText(node);
|
28300
28428
|
}
|
28429
|
+
updateSearchKey();
|
28301
28430
|
};
|
28302
28431
|
const handleClear = (e) => {
|
28303
28432
|
e.stopPropagation();
|
28433
|
+
store.value.clearChecked();
|
28434
|
+
searchKey.value = "";
|
28304
28435
|
updateValue([]);
|
28305
28436
|
emit("update:modelValue", []);
|
28306
28437
|
emit("clear", JSON.parse(JSON.stringify(props2.modelValue)));
|
@@ -28308,8 +28439,10 @@ var Component$6 = defineComponent({
|
|
28308
28439
|
const removeTag = (value, index, e) => {
|
28309
28440
|
e.stopPropagation();
|
28310
28441
|
const current = JSON.parse(JSON.stringify(value));
|
28311
|
-
current.splice(index, 1);
|
28442
|
+
const tag2 = current.splice(index, 1)[0];
|
28443
|
+
store.value.removeTag(tag2);
|
28312
28444
|
updateValue(current);
|
28445
|
+
emit("update:modelValue", store.value.getCheckedNodes().map((node) => node.path));
|
28313
28446
|
};
|
28314
28447
|
const modelValueChangeHandler = (value, oldValue) => {
|
28315
28448
|
updateValue(value);
|
@@ -28322,7 +28455,27 @@ var Component$6 = defineComponent({
|
|
28322
28455
|
};
|
28323
28456
|
const popoverChangeEmitter = (val) => {
|
28324
28457
|
emit("toggle", val.isShow);
|
28458
|
+
if (!val.isShow) {
|
28459
|
+
isFiltering.value = false;
|
28460
|
+
}
|
28325
28461
|
};
|
28462
|
+
const searchInputHandler = debounce(200, (e) => {
|
28463
|
+
const target = e.target;
|
28464
|
+
searchKey.value = target.value;
|
28465
|
+
if (searchKey.value === "") {
|
28466
|
+
isFiltering.value = false;
|
28467
|
+
return;
|
28468
|
+
}
|
28469
|
+
isFiltering.value = true;
|
28470
|
+
const targetNodes = store.value.getFlattedNodes().filter((node) => {
|
28471
|
+
if (props2.checkAnyLevel) {
|
28472
|
+
return node.pathNames.join(props2.separator).includes(searchKey.value);
|
28473
|
+
}
|
28474
|
+
return node.isLeaf && node.pathNames.join(props2.separator).includes(searchKey.value);
|
28475
|
+
});
|
28476
|
+
suggestions.value = targetNodes;
|
28477
|
+
!(popover3 == null ? void 0 : popover3.value.isShow) && (popover3 == null ? void 0 : popover3.value.show());
|
28478
|
+
});
|
28326
28479
|
watch(() => props2.modelValue, modelValueChangeHandler, {
|
28327
28480
|
immediate: true
|
28328
28481
|
});
|
@@ -28344,7 +28497,11 @@ var Component$6 = defineComponent({
|
|
28344
28497
|
selectedTags,
|
28345
28498
|
removeTag,
|
28346
28499
|
cascaderPanel,
|
28347
|
-
popoverChangeEmitter
|
28500
|
+
popoverChangeEmitter,
|
28501
|
+
searchKey,
|
28502
|
+
suggestions,
|
28503
|
+
isFiltering,
|
28504
|
+
searchInputHandler
|
28348
28505
|
};
|
28349
28506
|
},
|
28350
28507
|
render() {
|
@@ -28378,7 +28535,8 @@ var Component$6 = defineComponent({
|
|
28378
28535
|
"class": ["bk-cascader", "bk-cascader-wrapper", this.extCls, {
|
28379
28536
|
"bk-is-show-panel": this.panelShow,
|
28380
28537
|
"is-unselected": this.modelValue.length === 0,
|
28381
|
-
"is-hover": this.isHover
|
28538
|
+
"is-hover": this.isHover,
|
28539
|
+
"is-filterable": this.filterable
|
28382
28540
|
}],
|
28383
28541
|
"tabindex": "0",
|
28384
28542
|
"data-placeholder": this.placeholder,
|
@@ -28397,10 +28555,12 @@ var Component$6 = defineComponent({
|
|
28397
28555
|
}, {
|
28398
28556
|
default: () => createVNode("div", {
|
28399
28557
|
"class": "bk-cascader-name"
|
28400
|
-
}, [this.multiple && renderTags(), this.filterable ? createVNode("input", {
|
28558
|
+
}, [this.multiple && this.selectedTags.length > 0 && renderTags(), this.filterable ? createVNode("input", {
|
28401
28559
|
"class": "bk-cascader-search-input",
|
28402
28560
|
"type": "text",
|
28403
|
-
"
|
28561
|
+
"onInput": this.searchInputHandler,
|
28562
|
+
"placeholder": this.placeholder,
|
28563
|
+
"value": this.searchKey
|
28404
28564
|
}, null) : createVNode("span", null, [this.selectedText])]),
|
28405
28565
|
content: () => createVNode("div", {
|
28406
28566
|
"class": "bk-cascader-popover"
|
@@ -28409,6 +28569,10 @@ var Component$6 = defineComponent({
|
|
28409
28569
|
"ref": "cascaderPanel",
|
28410
28570
|
"width": this.scrollWidth,
|
28411
28571
|
"height": this.scrollHeight,
|
28572
|
+
"search-key": this.searchKey,
|
28573
|
+
"separator": this.separator,
|
28574
|
+
"is-filtering": this.isFiltering,
|
28575
|
+
"suggestions": this.suggestions,
|
28412
28576
|
"modelValue": this.checkedValue,
|
28413
28577
|
"onUpdate:modelValue": ($event) => this.checkedValue = $event
|
28414
28578
|
}, {
|