bkui-vue 0.0.1-beta.123 → 0.0.1-beta.124

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.esm.js CHANGED
@@ -9649,13 +9649,13 @@ const checkboxProps = {
9649
9649
  checked: PropTypes.bool.def(false),
9650
9650
  indeterminate: PropTypes.bool,
9651
9651
  beforeChange: PropTypes.func,
9652
- size: PropTypes.size()
9652
+ size: PropTypes.size().def("large")
9653
9653
  };
9654
9654
  var Component$v = defineComponent({
9655
9655
  name: "Checkbox",
9656
9656
  props: checkboxProps,
9657
9657
  emits: ["update:modelValue", "change"],
9658
- setup() {
9658
+ setup(props) {
9659
9659
  const [isFocus, {
9660
9660
  blur: handleBlur,
9661
9661
  focus: handleFocus
@@ -9673,7 +9673,8 @@ var Component$v = defineComponent({
9673
9673
  setChecked,
9674
9674
  handleBlur,
9675
9675
  handleFocus,
9676
- handleChange
9676
+ handleChange,
9677
+ size: props.size
9677
9678
  };
9678
9679
  },
9679
9680
  render() {
@@ -9687,7 +9688,7 @@ var Component$v = defineComponent({
9687
9688
  return createVNode("label", {
9688
9689
  "class": checkboxClass
9689
9690
  }, [createVNode("span", {
9690
- "class": "bk-checkbox-input"
9691
+ "class": [resolveClassName("checkbox-input"), this.size]
9691
9692
  }, [createVNode("input", {
9692
9693
  "role": "checkbox",
9693
9694
  "type": "checkbox",
@@ -23781,13 +23782,15 @@ var EVENTS = /* @__PURE__ */ ((EVENTS2) => {
23781
23782
  EVENTS2["NODE_CLICK"] = "nodeClick";
23782
23783
  EVENTS2["NODE_COLLAPSE"] = "nodeCollapse";
23783
23784
  EVENTS2["NODE_EXPAND"] = "nodeExpand";
23785
+ EVENTS2["NODE_CHECKED"] = "nodeChecked";
23784
23786
  return EVENTS2;
23785
23787
  })(EVENTS || {});
23786
23788
  const EMPTY = (..._args) => true;
23787
23789
  const TreeEmitEventsType = {
23788
23790
  ["nodeClick"]: EMPTY,
23789
23791
  ["nodeCollapse"]: EMPTY,
23790
- ["nodeExpand"]: EMPTY
23792
+ ["nodeExpand"]: EMPTY,
23793
+ ["nodeChecked"]: EMPTY
23791
23794
  };
23792
23795
  var NODE_ATTRIBUTES = /* @__PURE__ */ ((NODE_ATTRIBUTES2) => {
23793
23796
  NODE_ATTRIBUTES2["DEPTH"] = "__depth";
@@ -23866,6 +23869,8 @@ const treeProps = {
23866
23869
  draggable: PropTypes.bool.def(false),
23867
23870
  dragSort: PropTypes.bool.def(false),
23868
23871
  selectable: PropTypes.bool.def(true),
23872
+ showCheckbox: PropTypes.bool.def(false),
23873
+ showNodeTypeIcon: PropTypes.bool.def(true),
23869
23874
  selected: PropTypes.oneOfType([PropTypes.string, null, PropTypes.number, PropTypes.object]).def(null),
23870
23875
  autoCheckChildren: PropTypes.bool.def(true),
23871
23876
  autoOpenParentNode: PropTypes.bool.def(true)
@@ -23910,6 +23915,7 @@ var useNodeAttribute = (flatData, props) => {
23910
23915
  setNodeAttr(node, NODE_ATTRIBUTES.IS_LOADING, value);
23911
23916
  };
23912
23917
  const deleteNodeSchema = (id) => flatData.schema.delete(id);
23918
+ const getParentNode2 = (node) => getSchemaVal2(getNodeParentId(node));
23913
23919
  const isItemOpen = (item) => {
23914
23920
  var _a;
23915
23921
  if (typeof item === "object") {
@@ -23963,6 +23969,7 @@ var useNodeAttribute = (flatData, props) => {
23963
23969
  getNodeParentId,
23964
23970
  getNodeParentIdById,
23965
23971
  getParentNodeData,
23972
+ getParentNode: getParentNode2,
23966
23973
  setNodeAttr,
23967
23974
  getNodePath,
23968
23975
  isRootNode,
@@ -24151,6 +24158,8 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues, initOption)
24151
24158
  isItemOpen,
24152
24159
  isNodeOpened,
24153
24160
  isNodeLoading,
24161
+ isNodeChecked,
24162
+ getParentNode: getParentNode2,
24154
24163
  resolveScopedSlotParam,
24155
24164
  extendNodeAttr
24156
24165
  } = useNodeAttribute(flatData, props);
@@ -24162,9 +24171,9 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues, initOption)
24162
24171
  deepAutoOpen
24163
24172
  } = useNodeAsync(props, flatData);
24164
24173
  const getRootIcon = (item) => isItemOpen(item) ? createVNode(folderShapeOpen, {
24165
- "class": resolveClassName("tree-icon")
24174
+ "class": [resolveClassName("tree-icon"), resolveClassName("node-prefix")]
24166
24175
  }, null) : createVNode(folder, {
24167
- "class": resolveClassName("tree-icon")
24176
+ "class": [resolveClassName("tree-icon"), resolveClassName("node-prefix")]
24168
24177
  }, null);
24169
24178
  const renderPrefixVal = (val) => {
24170
24179
  if (typeof val === "string") {
@@ -24207,12 +24216,19 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues, initOption)
24207
24216
  }
24208
24217
  if (prefixFnVal === "default" || typeof props.prefixIcon === "boolean" && props.prefixIcon) {
24209
24218
  if (hasChildNode(item) || item.async || !props.autoCheckChildren) {
24210
- return isItemOpen(item) ? createVNode(downShape, null, null) : createVNode(rightShape, null, null);
24219
+ return isItemOpen(item) ? createVNode(downShape, {
24220
+ "class": resolveClassName("node-prefix")
24221
+ }, null) : createVNode(rightShape, {
24222
+ "class": resolveClassName("node-prefix")
24223
+ }, null);
24211
24224
  }
24212
24225
  }
24213
24226
  return null;
24214
24227
  };
24215
24228
  const getNodePrefixIcon = (item) => {
24229
+ if (!props.showNodeTypeIcon) {
24230
+ return null;
24231
+ }
24216
24232
  if (ctx.slots.nodeType) {
24217
24233
  return ctx.slots.nodeType(extendNodeAttr(item));
24218
24234
  }
@@ -24225,11 +24241,40 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues, initOption)
24225
24241
  }
24226
24242
  if (prefixFnVal === "default" || typeof props.prefixIcon === "boolean" && props.prefixIcon) {
24227
24243
  return isRootNode(item) || hasChildNode(item) ? getRootIcon(item) : createVNode(textFile, {
24228
- "class": resolveClassName("tree-icon")
24244
+ "class": [resolveClassName("tree-icon"), resolveClassName("node-prefix")]
24229
24245
  }, null);
24230
24246
  }
24231
24247
  return null;
24232
24248
  };
24249
+ const updateParentChecked = (item, isChecked) => {
24250
+ const parent = getParentNode2(item);
24251
+ const checked = isChecked || schemaValues.value.filter((node) => String.prototype.startsWith.call(getNodePath(node), getNodePath(item))).some((filterNode) => isNodeChecked(filterNode));
24252
+ if (parent) {
24253
+ setNodeAttr(parent, NODE_ATTRIBUTES.IS_CHECKED, checked);
24254
+ if (!isRootNode(parent)) {
24255
+ updateParentChecked(parent, isChecked);
24256
+ }
24257
+ }
24258
+ };
24259
+ const handleNodeItemCheckboxChange = (item, value) => {
24260
+ setNodeAttr(item, NODE_ATTRIBUTES.IS_CHECKED, !!value);
24261
+ schemaValues.value.filter((node) => String.prototype.startsWith.call(getNodePath(node), getNodePath(item))).forEach((filterNode) => setNodeAttr(filterNode, NODE_ATTRIBUTES.IS_CHECKED, !!value));
24262
+ updateParentChecked(item, value);
24263
+ ctx.emit(EVENTS.NODE_CHECKED, schemaValues.value.filter((t2) => isNodeChecked(t2)).map((n2) => n2[NODE_ATTRIBUTES.UUID]));
24264
+ };
24265
+ const isIndeterminate = (item) => isNodeChecked(item) && !schemaValues.value.filter((node) => String.prototype.startsWith.call(getNodePath(node), getNodePath(item))).every((filterNode) => isNodeChecked(filterNode));
24266
+ const isNodeItemChecked = (item) => isNodeChecked(item) || schemaValues.value.filter((node) => String.prototype.startsWith.call(getNodePath(node), getNodePath(item))).some((filterNode) => isNodeChecked(filterNode));
24267
+ const getCheckboxRender = (item) => {
24268
+ if (!props.showCheckbox) {
24269
+ return null;
24270
+ }
24271
+ return createVNode(BkCheckbox, {
24272
+ "size": "small",
24273
+ "modelValue": isNodeItemChecked(item),
24274
+ "indeterminate": isIndeterminate(item),
24275
+ "onChange": (val) => handleNodeItemCheckboxChange(item, val)
24276
+ }, null);
24277
+ };
24233
24278
  const setNodeOpened = (item, isOpen = null, e = null, fireEmit = true) => {
24234
24279
  const newVal = isOpen === null ? !isItemOpen(item) : !!isOpen;
24235
24280
  if (!newVal) {
@@ -24375,11 +24420,11 @@ var useNodeAction = (props, ctx, flatData, renderData, schemaValues, initOption)
24375
24420
  "style": getNodeItemStyle(item, props, flatData),
24376
24421
  "onClick": (e) => handleNodeContentClick(item, e)
24377
24422
  }, [createVNode("span", {
24378
- "class": resolveClassName("node-action"),
24423
+ "class": [resolveClassName("node-action")],
24379
24424
  "onClick": (e) => handleNodeActionClick(e, item)
24380
24425
  }, [getActionIcon(item)]), createVNode("span", {
24381
24426
  "class": resolveClassName("node-content")
24382
- }, [[getNodePrefixIcon(item)], createVNode("span", {
24427
+ }, [[getCheckboxRender(item), getNodePrefixIcon(item)], createVNode("span", {
24383
24428
  "class": resolveClassName("node-text")
24384
24429
  }, [(_c = (_b = (_a = ctx.slots).node) == null ? void 0 : _b.call(_a, extendNodeAttr(item))) != null ? _c : [getLabel(item, props)]]), (_e = (_d = ctx.slots).nodeAppend) == null ? void 0 : _e.call(_d, extendNodeAttr(item))]), getVirtualLines(item)])]);
24385
24430
  };
@@ -24562,6 +24607,7 @@ var useTreeInit = (props) => {
24562
24607
  data: data2,
24563
24608
  children
24564
24609
  } = props2;
24610
+ const checkedList = [];
24565
24611
  const outputData = [];
24566
24612
  let order2 = 0;
24567
24613
  const schema = /* @__PURE__ */ new Map();
@@ -24651,6 +24697,10 @@ var useTreeInit = (props) => {
24651
24697
  Object.assign(item, {
24652
24698
  [NODE_ATTRIBUTES.UUID]: uuid2
24653
24699
  });
24700
+ const isChecked = props2.showCheckbox && getCachedTreeNodeAttr(uuid2, item, NODE_ATTRIBUTES.IS_CHECKED);
24701
+ if (isChecked) {
24702
+ checkedList.push(uuid2);
24703
+ }
24654
24704
  schema.set(uuid2, {
24655
24705
  [NODE_ATTRIBUTES.DEPTH]: depth,
24656
24706
  [NODE_ATTRIBUTES.INDEX]: i2,
@@ -24663,7 +24713,7 @@ var useTreeInit = (props) => {
24663
24713
  [NODE_ATTRIBUTES.IS_SELECTED]: isCachedTreeNodeSelected(uuid2, item),
24664
24714
  [NODE_ATTRIBUTES.IS_MATCH]: getCachedTreeNodeAttr(uuid2, item, NODE_ATTRIBUTES.IS_MATCH),
24665
24715
  [NODE_ATTRIBUTES.IS_OPEN]: isOpened,
24666
- [NODE_ATTRIBUTES.IS_CHECKED]: getCachedTreeNodeAttr(uuid2, item, NODE_ATTRIBUTES.IS_CHECKED),
24716
+ [NODE_ATTRIBUTES.IS_CHECKED]: isChecked,
24667
24717
  [NODE_ATTRIBUTES.IS_CACHED]: getCachedTreeNodeAttr(uuid2, item, NODE_ATTRIBUTES.IS_CACHED),
24668
24718
  [NODE_ATTRIBUTES.IS_ASYNC]: getCachedTreeNodeAttr(uuid2, item, NODE_ATTRIBUTES.IS_ASYNC),
24669
24719
  [NODE_ATTRIBUTES.IS_LOADING]: getCachedTreeNodeAttr(uuid2, item, NODE_ATTRIBUTES.IS_LOADING),
@@ -24682,6 +24732,14 @@ var useTreeInit = (props) => {
24682
24732
  }
24683
24733
  }
24684
24734
  flatten(treeData ? treeData : data2);
24735
+ if (props2.showCheckbox) {
24736
+ checkedList == null ? void 0 : checkedList.forEach((value) => {
24737
+ Array.from(schema.values()).filter((t2) => t2[NODE_ATTRIBUTES.PATH].startsWith(schema.get(value)[NODE_ATTRIBUTES.PATH])).forEach((n2) => Object.assign(n2, {
24738
+ [NODE_ATTRIBUTES.IS_CHECKED]: true
24739
+ }));
24740
+ loopUpdateNodeAttr(value, NODE_ATTRIBUTES.IS_CHECKED, true, () => true);
24741
+ });
24742
+ }
24685
24743
  return [outputData, schema];
24686
24744
  };
24687
24745
  const formatData = getFlatdata(props);