bkui-vue 0.0.1-beta.189 → 0.0.1-beta.190

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
@@ -16065,7 +16065,8 @@ const TABLE_ROW_ATTRIBUTE = {
16065
16065
  ROW_UID: "__$uuid",
16066
16066
  ROW_EXPAND: "__row_expand",
16067
16067
  ROW_SELECTION: "__row_selection",
16068
- ROW_SELECTION_ALL: "__row_selection_all"
16068
+ ROW_SELECTION_ALL: "__row_selection_all",
16069
+ ROW_SELECTION_INDETERMINATE: "__row_selection_indeterminate"
16069
16070
  };
16070
16071
  const SCROLLY_WIDTH = 4;
16071
16072
  const LINE_HEIGHT = 42;
@@ -16999,7 +17000,7 @@ var TableCell = defineComponent({
16999
17000
  const refRoot = ref();
17000
17001
  const isTipsEnabled = ref(false);
17001
17002
  const resolveSetting = () => {
17002
- if (/boolean|object/.test(props2.column.showOverflowTooltip) && props2.column.showOverflowTooltip !== null) {
17003
+ if (/boolean|object/.test(typeof props2.column.showOverflowTooltip) && props2.column.showOverflowTooltip !== null) {
17003
17004
  return props2.column;
17004
17005
  }
17005
17006
  return {
@@ -17030,12 +17031,18 @@ var TableCell = defineComponent({
17030
17031
  };
17031
17032
  };
17032
17033
  const resolveOverflowTooltip = () => {
17033
- if (!refRoot.value) {
17034
+ if (!refRoot.value || /selection|index|expand/.test(props2.column.type) || !isElement$2(refRoot.value)) {
17034
17035
  return;
17035
17036
  }
17036
- const textWidth = getElementTextWidth(refRoot.value);
17037
+ const {
17038
+ content
17039
+ } = resolveTooltipOption();
17040
+ const textWidth = getElementTextWidth(refRoot.value, content);
17037
17041
  const cellWidth = refRoot.value.clientWidth;
17038
- isTipsEnabled.value = textWidth > cellWidth;
17042
+ const computedStyle = window.getComputedStyle(refRoot.value);
17043
+ const paddingWidth = ["padding-left", "padding-right"].reduce((width, prop) => width + Number(computedStyle.getPropertyValue(prop).replace("px", "")), 0);
17044
+ const cellInnerWidth = cellWidth - paddingWidth;
17045
+ isTipsEnabled.value = textWidth > cellInnerWidth;
17039
17046
  if (isTipsEnabled.value) {
17040
17047
  const bindings = ref(resolveTooltipOption());
17041
17048
  if (bkEllipsisIns === null) {
@@ -17782,7 +17789,10 @@ class TableRender {
17782
17789
  };
17783
17790
  const renderHeadCell = (column, index) => {
17784
17791
  if (column.type === "selection") {
17785
- return this.renderCheckboxColumn({}, 0, true);
17792
+ const selectAll = this.reactiveProp.rowActions.get(TABLE_ROW_ATTRIBUTE.ROW_SELECTION_ALL);
17793
+ return this.renderCheckboxColumn({
17794
+ [TABLE_ROW_ATTRIBUTE.ROW_SELECTION]: !!selectAll
17795
+ }, 0, true);
17786
17796
  }
17787
17797
  const cells = [];
17788
17798
  if (column.sort) {
@@ -17945,9 +17955,11 @@ class TableRender {
17945
17955
  value
17946
17956
  }]);
17947
17957
  };
17958
+ const indeterminate = isAll && !!this.reactiveProp.rowActions.get(TABLE_ROW_ATTRIBUTE.ROW_SELECTION_INDETERMINATE);
17948
17959
  return createVNode(BkCheckbox, {
17949
17960
  "onChange": handleChecked,
17950
- "modelValue": row[TABLE_ROW_ATTRIBUTE.ROW_SELECTION]
17961
+ "modelValue": row[TABLE_ROW_ATTRIBUTE.ROW_SELECTION],
17962
+ "indeterminate": indeterminate
17951
17963
  }, null);
17952
17964
  }
17953
17965
  renderExpandColumn(row, column, index, rows) {
@@ -18375,10 +18387,43 @@ const useInit = (props2, targetColumns) => {
18375
18387
  }
18376
18388
  return false;
18377
18389
  };
18390
+ const validateSelectionFn = (row) => {
18391
+ const rowId = row[TABLE_ROW_ATTRIBUTE.ROW_UID];
18392
+ const { isSelected = false } = reactiveSchema.rowActions.get(rowId) || {};
18393
+ return isSelected;
18394
+ };
18395
+ const updateSelectionAll = (validateFn = validateSelectionFn) => {
18396
+ let hasUnchecked = false;
18397
+ let hasChecked = false;
18398
+ indexData.forEach((row) => {
18399
+ const isSelected = validateFn(row);
18400
+ if (!hasUnchecked && !isSelected) {
18401
+ hasUnchecked = true;
18402
+ }
18403
+ if (!hasChecked && isSelected) {
18404
+ hasChecked = true;
18405
+ }
18406
+ });
18407
+ reactiveSchema.rowActions.set(TABLE_ROW_ATTRIBUTE.ROW_SELECTION_ALL, hasChecked && !hasUnchecked);
18408
+ reactiveSchema.rowActions.set(TABLE_ROW_ATTRIBUTE.ROW_SELECTION_INDETERMINATE, hasChecked && hasUnchecked);
18409
+ };
18410
+ const isSelectionEnable = () => props2.columns.some((col) => col.type === "selection");
18411
+ const initSelectionAllByData = () => {
18412
+ if (isSelectionEnable()) {
18413
+ updateSelectionAll((row) => resolveSelectionRow(row));
18414
+ }
18415
+ };
18378
18416
  const toggleAllSelection = (checked = void 0) => {
18379
18417
  const isChecked = typeof checked === "boolean" ? checked : !isSelectionAll();
18380
18418
  reactiveSchema.rowActions.set(TABLE_ROW_ATTRIBUTE.ROW_SELECTION_ALL, isChecked);
18381
- updateIndexData();
18419
+ reactiveSchema.rowActions.set(TABLE_ROW_ATTRIBUTE.ROW_SELECTION_INDETERMINATE, false);
18420
+ indexData.forEach((row) => {
18421
+ var _a2;
18422
+ const rowId = row[TABLE_ROW_ATTRIBUTE.ROW_UID];
18423
+ const target = Object.assign({}, (_a2 = reactiveSchema.rowActions.get(rowId)) != null ? _a2 : {}, { isSelected: isChecked });
18424
+ reactiveSchema.rowActions.set(rowId, target);
18425
+ });
18426
+ updateIndexData(isChecked);
18382
18427
  asyncSelection(null, checked, true);
18383
18428
  };
18384
18429
  const clearSelection = () => {
@@ -18391,6 +18436,10 @@ const useInit = (props2, targetColumns) => {
18391
18436
  const isSelected = typeof selected === "boolean" ? selected : !resolveSelection(row, rowId);
18392
18437
  const target = Object.assign({}, (_a2 = reactiveSchema.rowActions.get(rowId)) != null ? _a2 : {}, { isSelected });
18393
18438
  reactiveSchema.rowActions.set(rowId, target);
18439
+ if (!selected) {
18440
+ reactiveSchema.rowActions.set(TABLE_ROW_ATTRIBUTE.ROW_SELECTION_ALL, false);
18441
+ }
18442
+ updateSelectionAll();
18394
18443
  updateIndexData();
18395
18444
  asyncSelection(row, selected, false);
18396
18445
  }
@@ -18404,17 +18453,15 @@ const useInit = (props2, targetColumns) => {
18404
18453
  }
18405
18454
  return thenFn();
18406
18455
  };
18407
- const resolveSelection = (row, rowId) => resolveSelectionRow(row, () => {
18456
+ const resolveSelection = (row, _rowId) => resolveSelectionRow(row, () => {
18408
18457
  var _a2;
18458
+ const rowId = _rowId === void 0 ? row[TABLE_ROW_ATTRIBUTE.ROW_UID] : _rowId;
18409
18459
  if (isSelectionAll()) {
18410
18460
  return true;
18411
18461
  }
18412
18462
  if (reactiveSchema.rowActions.has(rowId)) {
18413
18463
  return (_a2 = reactiveSchema.rowActions.get(rowId)) == null ? void 0 : _a2.isSelected;
18414
18464
  }
18415
- if (Object.prototype.hasOwnProperty.call(row, TABLE_ROW_ATTRIBUTE.ROW_SELECTION) && typeof row[TABLE_ROW_ATTRIBUTE.ROW_SELECTION] === "boolean") {
18416
- return row[TABLE_ROW_ATTRIBUTE.ROW_SELECTION];
18417
- }
18418
18465
  return false;
18419
18466
  });
18420
18467
  const indexData = reactive([]);
@@ -18428,14 +18475,18 @@ const useInit = (props2, targetColumns) => {
18428
18475
  [TABLE_ROW_ATTRIBUTE.ROW_SELECTION]: resolveSelection(item, rowId)
18429
18476
  });
18430
18477
  }));
18478
+ initSelectionAllByData();
18431
18479
  };
18432
- const updateIndexData = () => {
18480
+ const updateIndexData = (selectedAll) => {
18433
18481
  indexData.forEach((item) => {
18434
18482
  Object.assign(item, {
18435
18483
  [TABLE_ROW_ATTRIBUTE.ROW_EXPAND]: isRowExpand(item[TABLE_ROW_ATTRIBUTE.ROW_UID]),
18436
- [TABLE_ROW_ATTRIBUTE.ROW_SELECTION]: resolveSelection(item, item[TABLE_ROW_ATTRIBUTE.ROW_UID])
18484
+ [TABLE_ROW_ATTRIBUTE.ROW_SELECTION]: typeof selectedAll === "boolean" ? selectedAll : resolveSelection(item, item[TABLE_ROW_ATTRIBUTE.ROW_UID])
18437
18485
  });
18438
18486
  });
18487
+ if (typeof selectedAll !== "boolean") {
18488
+ initSelectionAllByData();
18489
+ }
18439
18490
  };
18440
18491
  const asyncSelection = (row, value, all = false) => {
18441
18492
  if (props2.asyncData && props2.rowKey) {
@@ -18454,6 +18505,7 @@ const useInit = (props2, targetColumns) => {
18454
18505
  }
18455
18506
  };
18456
18507
  const { renderFixedColumns, fixedWrapperClass } = useFixedColumn(props2, colgroups, false);
18508
+ const getSelection = () => indexData.filter((row) => resolveSelection(row));
18457
18509
  return {
18458
18510
  colgroups,
18459
18511
  dragOffsetXStyle,
@@ -18468,7 +18520,8 @@ const useInit = (props2, targetColumns) => {
18468
18520
  updateColGroups,
18469
18521
  clearSelection,
18470
18522
  toggleAllSelection,
18471
- toggleRowSelection
18523
+ toggleRowSelection,
18524
+ getSelection
18472
18525
  };
18473
18526
  };
18474
18527
  var Component$d = defineComponent({
@@ -18500,7 +18553,8 @@ var Component$d = defineComponent({
18500
18553
  fixedWrapperClass,
18501
18554
  clearSelection,
18502
18555
  toggleAllSelection,
18503
- toggleRowSelection
18556
+ toggleRowSelection,
18557
+ getSelection
18504
18558
  } = useInit(props2, targetColumns);
18505
18559
  const {
18506
18560
  pageData,
@@ -18694,7 +18748,8 @@ var Component$d = defineComponent({
18694
18748
  setRowExpand,
18695
18749
  clearSelection,
18696
18750
  toggleAllSelection,
18697
- toggleRowSelection
18751
+ toggleRowSelection,
18752
+ getSelection
18698
18753
  });
18699
18754
  const tableBodyClass = computed(() => __spreadProps(__spreadValues({}, contentClass), {
18700
18755
  "__is-empty": !pageData.length