bkui-vue 0.0.1-beta.187 → 0.0.1-beta.188

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
@@ -16018,6 +16018,7 @@ var EVENTS$1 = /* @__PURE__ */ ((EVENTS2) => {
16018
16018
  EVENTS2["ON_FILTER_CLICK"] = "onFilterClick";
16019
16019
  EVENTS2["ON_SETTING_CHANGE"] = "onSettingChange";
16020
16020
  EVENTS2["ON_ROW_EXPAND_CLICK"] = "onRowExpandClick";
16021
+ EVENTS2["ON_ROW_CHECK"] = "onRowCheck";
16021
16022
  return EVENTS2;
16022
16023
  })(EVENTS$1 || {});
16023
16024
  var EMITEVENTS = /* @__PURE__ */ ((EMITEVENTS2) => {
@@ -16032,6 +16033,9 @@ var EMITEVENTS = /* @__PURE__ */ ((EMITEVENTS2) => {
16032
16033
  EMITEVENTS2["PAGE_VALUE_CHANGE"] = "pageValueChange";
16033
16034
  EMITEVENTS2["SETTING_CHANGE"] = "settingChange";
16034
16035
  EMITEVENTS2["SCROLL_BOTTOM"] = "scrollBottom";
16036
+ EMITEVENTS2["ROW_SELECT"] = "select";
16037
+ EMITEVENTS2["ROW_SELECT_ALL"] = "selectAll";
16038
+ EMITEVENTS2["ROW_SELECT_CHANGE"] = "selectionChange";
16035
16039
  return EMITEVENTS2;
16036
16040
  })(EMITEVENTS || {});
16037
16041
  const EMPTY$1 = (..._args) => true;
@@ -16039,19 +16043,24 @@ const EMIT_EVENT_TYPES = {
16039
16043
  ["columnPick"]: EMPTY$1,
16040
16044
  ["columnFilter"]: EMPTY$1,
16041
16045
  ["columnSort"]: EMPTY$1,
16046
+ ["colFilterSave"]: EMPTY$1,
16042
16047
  ["rowClick"]: EMPTY$1,
16043
16048
  ["rowDblclick"]: EMPTY$1,
16044
16049
  ["rowExpand"]: EMPTY$1,
16050
+ ["select"]: EMPTY$1,
16051
+ ["selectAll"]: EMPTY$1,
16052
+ ["selectionChange"]: EMPTY$1,
16045
16053
  ["pageLimitChange"]: EMPTY$1,
16046
16054
  ["pageValueChange"]: EMPTY$1,
16047
16055
  ["settingChange"]: EMPTY$1,
16048
- ["scrollBottom"]: EMPTY$1,
16049
- ["colFilterSave"]: EMPTY$1
16056
+ ["scrollBottom"]: EMPTY$1
16050
16057
  };
16051
16058
  const TABLE_ROW_ATTRIBUTE = {
16052
16059
  ROW_INDEX: "__$table_row_index",
16053
16060
  ROW_UID: "__$uuid",
16054
- ROW_EXPAND: "__row_expand"
16061
+ ROW_EXPAND: "__row_expand",
16062
+ ROW_SELECTION: "__row_selection",
16063
+ ROW_SELECTION_ALL: "__row_selection_all"
16055
16064
  };
16056
16065
  const SCROLLY_WIDTH = 4;
16057
16066
  const LINE_HEIGHT = 42;
@@ -16082,7 +16091,7 @@ const IColumnType = {
16082
16091
  content: PropTypes.string.def(""),
16083
16092
  disabled: PropTypes.bool.def(false),
16084
16093
  watchCellResize: PropTypes.bool.def(true)
16085
- })]).def(false),
16094
+ })]).def(void 0),
16086
16095
  type: PropTypes.commonType(["selection", "index", "expand", "none"], "columnType").def("none"),
16087
16096
  resizable: PropTypes.bool.def(true),
16088
16097
  fixed: PropTypes.oneOfType([
@@ -16154,10 +16163,18 @@ const tableProps = {
16154
16163
  PropTypes.bool
16155
16164
  ]).def(void 0),
16156
16165
  reserveExpand: PropTypes.bool.def(false),
16166
+ selectionKey: PropTypes.string.def(""),
16167
+ isSelectedFn: PropTypes.func.def(void 0),
16157
16168
  rowKey: PropTypes.oneOfType([
16158
16169
  PropTypes.string,
16159
16170
  PropTypes.func
16160
- ]).def(TABLE_ROW_ATTRIBUTE.ROW_INDEX)
16171
+ ]).def(TABLE_ROW_ATTRIBUTE.ROW_INDEX),
16172
+ showOverflowTooltip: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
16173
+ content: PropTypes.string.def(""),
16174
+ disabled: PropTypes.bool.def(false),
16175
+ watchCellResize: PropTypes.bool.def(true)
16176
+ })]).def(false),
16177
+ asyncData: PropTypes.bool.def(false)
16161
16178
  };
16162
16179
  var Column = defineComponent({
16163
16180
  name: "TableColumn",
@@ -16202,7 +16219,7 @@ const resolvePaginationOption = (propPagination, defVal) => {
16202
16219
  }
16203
16220
  return {};
16204
16221
  };
16205
- var userPagination = (props2, indexData) => {
16222
+ var usePagination = (props2, indexData) => {
16206
16223
  const startIndex = ref(0);
16207
16224
  const endIndex = ref(0);
16208
16225
  let pagination2 = reactive({
@@ -16925,13 +16942,7 @@ const getRowKey = (item, props2, index) => {
16925
16942
  if (props2.rowKey === TABLE_ROW_ATTRIBUTE.ROW_INDEX) {
16926
16943
  return `__ROW_INDEX_${index}`;
16927
16944
  }
16928
- const keys = props2.rowKey.split(".");
16929
- return keys.reduce((pre, cur) => {
16930
- if (Object.prototype.hasOwnProperty.call(pre, cur)) {
16931
- return pre[cur];
16932
- }
16933
- return pre;
16934
- }, item);
16945
+ return lodash.exports.get(item, props2.rowKey);
16935
16946
  }
16936
16947
  if (typeof props2.rowKey === "function") {
16937
16948
  return Reflect.apply(props2.rowKey, globalThis, [item]);
@@ -16970,16 +16981,29 @@ var TableCell = defineComponent({
16970
16981
  name: "TableCell",
16971
16982
  props: {
16972
16983
  column: PropTypes.any.def({}),
16973
- row: PropTypes.any.def({})
16984
+ row: PropTypes.any.def({}),
16985
+ parentSetting: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
16986
+ content: PropTypes.string.def(""),
16987
+ disabled: PropTypes.bool.def(false),
16988
+ watchCellResize: PropTypes.bool.def(true)
16989
+ })]).def(void 0)
16974
16990
  },
16975
16991
  setup(props2, {
16976
16992
  slots
16977
16993
  }) {
16978
16994
  const refRoot = ref();
16979
16995
  const isTipsEnabled = ref(false);
16996
+ const resolveSetting = () => {
16997
+ if (/boolean|object/.test(props2.column.showOverflowTooltip) && props2.column.showOverflowTooltip !== null) {
16998
+ return props2.column;
16999
+ }
17000
+ return {
17001
+ showOverflowTooltip: props2.parentSetting
17002
+ };
17003
+ };
16980
17004
  const {
16981
17005
  showOverflowTooltip = false
16982
- } = props2.column || {};
17006
+ } = resolveSetting();
16983
17007
  let observerIns = null;
16984
17008
  let bkEllipsisIns = null;
16985
17009
  const resolveTooltipOption = () => {
@@ -17752,6 +17776,9 @@ class TableRender {
17752
17776
  "--row-height": `${resolvePropVal(config, "height", ["thead"])}px`
17753
17777
  };
17754
17778
  const renderHeadCell = (column, index) => {
17779
+ if (column.type === "selection") {
17780
+ return this.renderCheckboxColumn({}, 0, true);
17781
+ }
17755
17782
  const cells = [];
17756
17783
  if (column.sort) {
17757
17784
  cells.push(this.getSortCell(column, index));
@@ -17840,7 +17867,8 @@ class TableRender {
17840
17867
  }, [createVNode(TableCell, {
17841
17868
  "class": tdCtxClass,
17842
17869
  "column": column,
17843
- "row": row
17870
+ "row": row,
17871
+ "parentSetting": this.props.showOverflowTooltip
17844
17872
  }, _isSlot$1(_slot2 = this.renderCell(row, column, rowIndex, rows)) ? _slot2 : {
17845
17873
  default: () => [_slot2]
17846
17874
  })]);
@@ -17891,38 +17919,64 @@ class TableRender {
17891
17919
  e
17892
17920
  }]);
17893
17921
  }
17894
- renderCell(row, column, index, rows) {
17895
- if (column.type === "expand") {
17896
- const renderExpandSlot = () => {
17897
- var _a, _b, _c;
17898
- if (typeof column.render === "function") {
17899
- return column.render(null, row, index, rows);
17900
- }
17901
- return (_c = (_b = (_a = this.context.slots).expandCell) == null ? void 0 : _b.call(_a, {
17902
- row,
17903
- column,
17904
- index,
17905
- rows
17906
- })) != null ? _c : this.getExpandCell(row);
17907
- };
17908
- return createVNode("span", {
17909
- "class": "expand-btn-action",
17910
- "onClick": (e) => this.handleRowExpandClick(row, column, index, rows, e)
17911
- }, [renderExpandSlot()]);
17912
- }
17922
+ renderCellCallbackFn(row, column, index, rows) {
17913
17923
  const cell = getRowText(row, resolvePropVal(column, "field", [column, row]), column);
17914
- if (typeof column.render === "function") {
17915
- const data2 = this.props.data[row[TABLE_ROW_ATTRIBUTE.ROW_INDEX]];
17916
- return column.render({
17917
- cell,
17918
- data: data2,
17924
+ const data2 = this.props.data[row[TABLE_ROW_ATTRIBUTE.ROW_INDEX]];
17925
+ return column.render({
17926
+ cell,
17927
+ data: data2,
17928
+ row,
17929
+ column,
17930
+ index,
17931
+ rows
17932
+ });
17933
+ }
17934
+ renderCheckboxColumn(row, index, isAll = false) {
17935
+ const handleChecked = (value) => {
17936
+ this.emitEvent(EVENTS$1.ON_ROW_CHECK, [{
17937
+ row,
17938
+ index,
17939
+ isAll,
17940
+ value
17941
+ }]);
17942
+ };
17943
+ return createVNode(BkCheckbox, {
17944
+ "onChange": handleChecked,
17945
+ "modelValue": row[TABLE_ROW_ATTRIBUTE.ROW_SELECTION]
17946
+ }, null);
17947
+ }
17948
+ renderExpandColumn(row, column, index, rows) {
17949
+ const renderExpandSlot = () => {
17950
+ var _a, _b, _c;
17951
+ if (typeof column.render === "function") {
17952
+ return this.renderCellCallbackFn(row, column, index, rows);
17953
+ }
17954
+ return (_c = (_b = (_a = this.context.slots).expandCell) == null ? void 0 : _b.call(_a, {
17919
17955
  row,
17920
17956
  column,
17921
17957
  index,
17922
17958
  rows
17923
- });
17924
- }
17925
- return cell;
17959
+ })) != null ? _c : this.getExpandCell(row);
17960
+ };
17961
+ return createVNode("span", {
17962
+ "class": "expand-btn-action",
17963
+ "onClick": (e) => this.handleRowExpandClick(row, column, index, rows, e)
17964
+ }, [renderExpandSlot()]);
17965
+ }
17966
+ renderCell(row, column, index, rows) {
17967
+ var _a, _b;
17968
+ const defaultFn = () => {
17969
+ const cell = getRowText(row, resolvePropVal(column, "field", [column, row]), column);
17970
+ if (typeof column.render === "function") {
17971
+ return this.renderCellCallbackFn(row, column, index, rows);
17972
+ }
17973
+ return cell;
17974
+ };
17975
+ const renderFn = {
17976
+ expand: (row2, column2, index2, rows2) => this.renderExpandColumn(row2, column2, index2, rows2),
17977
+ selection: (row2, _column, index2, _rows) => this.renderCheckboxColumn(row2, index2)
17978
+ };
17979
+ return (_b = (_a = renderFn[column.type]) == null ? void 0 : _a.call(renderFn, row, column, index, rows)) != null ? _b : defaultFn();
17926
17980
  }
17927
17981
  isColActive(colIndex) {
17928
17982
  return this.props.columnPick !== "disabled" && this.propActiveCols.some((col) => col.index === colIndex && col.active);
@@ -18307,6 +18361,57 @@ const useInit = (props2, targetColumns) => {
18307
18361
  reactiveSchema.rowActions.set(rowId, Object.assign({}, (_a2 = reactiveSchema.rowActions.get(rowId)) != null ? _a2 : {}, { isExpand }));
18308
18362
  updateIndexData();
18309
18363
  };
18364
+ const isSelectionAll = () => {
18365
+ if (reactiveSchema.rowActions.has(TABLE_ROW_ATTRIBUTE.ROW_SELECTION_ALL)) {
18366
+ return reactiveSchema.rowActions.get(TABLE_ROW_ATTRIBUTE.ROW_SELECTION_ALL);
18367
+ }
18368
+ if (!!props2.selectionKey) {
18369
+ return indexData.every((row) => resolveSelectionRow(row));
18370
+ }
18371
+ return false;
18372
+ };
18373
+ const toggleAllSelection = (checked = void 0) => {
18374
+ const isChecked = typeof checked === "boolean" ? checked : !isSelectionAll();
18375
+ reactiveSchema.rowActions.set(TABLE_ROW_ATTRIBUTE.ROW_SELECTION_ALL, isChecked);
18376
+ updateIndexData();
18377
+ asyncSelection(null, checked, true);
18378
+ };
18379
+ const clearSelection = () => {
18380
+ toggleAllSelection(false);
18381
+ };
18382
+ const toggleRowSelection = (row, selected) => {
18383
+ var _a2;
18384
+ const rowId = row[TABLE_ROW_ATTRIBUTE.ROW_UID];
18385
+ if (rowId) {
18386
+ const isSelected = typeof selected === "boolean" ? selected : !resolveSelection(row, rowId);
18387
+ const target = Object.assign({}, (_a2 = reactiveSchema.rowActions.get(rowId)) != null ? _a2 : {}, { isSelected });
18388
+ reactiveSchema.rowActions.set(rowId, target);
18389
+ updateIndexData();
18390
+ asyncSelection(row, selected, false);
18391
+ }
18392
+ };
18393
+ const resolveSelectionRow = (row, thenFn = () => false) => {
18394
+ if (typeof props2.isSelectedFn === "function") {
18395
+ return Reflect.apply(props2.isSelectedFn, globalThis, [{ row, data: props2.data }]);
18396
+ }
18397
+ if (typeof props2.selectionKey === "string" && props2.selectionKey.length) {
18398
+ return lodash.exports.get(row, props2.selectionKey);
18399
+ }
18400
+ return thenFn();
18401
+ };
18402
+ const resolveSelection = (row, rowId) => resolveSelectionRow(row, () => {
18403
+ var _a2;
18404
+ if (isSelectionAll()) {
18405
+ return true;
18406
+ }
18407
+ if (reactiveSchema.rowActions.has(rowId)) {
18408
+ return (_a2 = reactiveSchema.rowActions.get(rowId)) == null ? void 0 : _a2.isSelected;
18409
+ }
18410
+ if (Object.prototype.hasOwnProperty.call(row, TABLE_ROW_ATTRIBUTE.ROW_SELECTION) && typeof row[TABLE_ROW_ATTRIBUTE.ROW_SELECTION] === "boolean") {
18411
+ return row[TABLE_ROW_ATTRIBUTE.ROW_SELECTION];
18412
+ }
18413
+ return false;
18414
+ });
18310
18415
  const indexData = reactive([]);
18311
18416
  const initIndexData = (keepLocalAction = false) => {
18312
18417
  indexData.splice(0, indexData.length, ...props2.data.map((item, index) => {
@@ -18314,17 +18419,35 @@ const useInit = (props2, targetColumns) => {
18314
18419
  return __spreadProps(__spreadValues({}, item), {
18315
18420
  [TABLE_ROW_ATTRIBUTE.ROW_INDEX]: index,
18316
18421
  [TABLE_ROW_ATTRIBUTE.ROW_UID]: rowId,
18317
- [TABLE_ROW_ATTRIBUTE.ROW_EXPAND]: keepLocalAction ? isRowExpand(rowId) : false
18422
+ [TABLE_ROW_ATTRIBUTE.ROW_EXPAND]: keepLocalAction ? isRowExpand(rowId) : false,
18423
+ [TABLE_ROW_ATTRIBUTE.ROW_SELECTION]: resolveSelection(item, rowId)
18318
18424
  });
18319
18425
  }));
18320
18426
  };
18321
18427
  const updateIndexData = () => {
18322
18428
  indexData.forEach((item) => {
18323
18429
  Object.assign(item, {
18324
- [TABLE_ROW_ATTRIBUTE.ROW_EXPAND]: isRowExpand(item[TABLE_ROW_ATTRIBUTE.ROW_UID])
18430
+ [TABLE_ROW_ATTRIBUTE.ROW_EXPAND]: isRowExpand(item[TABLE_ROW_ATTRIBUTE.ROW_UID]),
18431
+ [TABLE_ROW_ATTRIBUTE.ROW_SELECTION]: resolveSelection(item, item[TABLE_ROW_ATTRIBUTE.ROW_UID])
18325
18432
  });
18326
18433
  });
18327
18434
  };
18435
+ const asyncSelection = (row, value, all = false) => {
18436
+ if (props2.asyncData && props2.rowKey) {
18437
+ if (all) {
18438
+ props2.data.forEach((item) => {
18439
+ if (lodash.exports.has(item, props2.selectionKey)) {
18440
+ lodash.exports.set(item, props2.selectionKey, !!value);
18441
+ }
18442
+ });
18443
+ } else {
18444
+ if (lodash.exports.has(row, props2.selectionKey)) {
18445
+ const target = props2.data.find((item) => lodash.exports.get(item, props2.rowKey) === lodash.exports.get(row, props2.rowKey));
18446
+ lodash.exports.set(target, props2.selectionKey, !!value);
18447
+ }
18448
+ }
18449
+ }
18450
+ };
18328
18451
  const { renderFixedColumns, fixedWrapperClass } = useFixedColumn(props2, colgroups, false);
18329
18452
  return {
18330
18453
  colgroups,
@@ -18337,7 +18460,10 @@ const useInit = (props2, targetColumns) => {
18337
18460
  updateIndexData,
18338
18461
  renderFixedColumns,
18339
18462
  setRowExpand,
18340
- updateColGroups
18463
+ updateColGroups,
18464
+ clearSelection,
18465
+ toggleAllSelection,
18466
+ toggleRowSelection
18341
18467
  };
18342
18468
  };
18343
18469
  var Component$d = defineComponent({
@@ -18366,14 +18492,17 @@ var Component$d = defineComponent({
18366
18492
  renderFixedColumns,
18367
18493
  setRowExpand,
18368
18494
  initIndexData,
18369
- fixedWrapperClass
18495
+ fixedWrapperClass,
18496
+ clearSelection,
18497
+ toggleAllSelection,
18498
+ toggleRowSelection
18370
18499
  } = useInit(props2, targetColumns);
18371
18500
  const {
18372
18501
  pageData,
18373
18502
  localPagination,
18374
18503
  resolvePageData,
18375
18504
  watchEffectFn
18376
- } = userPagination(props2, indexData);
18505
+ } = usePagination(props2, indexData);
18377
18506
  const {
18378
18507
  tableClass,
18379
18508
  headClass,
@@ -18486,6 +18615,34 @@ var Component$d = defineComponent({
18486
18615
  e
18487
18616
  });
18488
18617
  setRowExpand(row, !row[TABLE_ROW_ATTRIBUTE.ROW_EXPAND]);
18618
+ }).on(EVENTS$1.ON_ROW_CHECK, ({
18619
+ row,
18620
+ isAll,
18621
+ index,
18622
+ value
18623
+ }) => {
18624
+ if (isAll) {
18625
+ toggleAllSelection(value);
18626
+ ctx.emit(EMITEVENTS.ROW_SELECT_ALL, {
18627
+ checked: value,
18628
+ data: props2.data
18629
+ });
18630
+ } else {
18631
+ toggleRowSelection(row, value);
18632
+ ctx.emit(EMITEVENTS.ROW_SELECT, {
18633
+ row,
18634
+ index,
18635
+ checked: value,
18636
+ data: props2.data
18637
+ });
18638
+ }
18639
+ ctx.emit(EMITEVENTS.ROW_SELECT_CHANGE, {
18640
+ row,
18641
+ isAll,
18642
+ index,
18643
+ checked: value,
18644
+ data: props2.data
18645
+ });
18489
18646
  });
18490
18647
  const handleScrollChanged = (args) => {
18491
18648
  var _a;
@@ -18529,7 +18686,10 @@ var Component$d = defineComponent({
18529
18686
  tableRender.destroy();
18530
18687
  });
18531
18688
  ctx.expose({
18532
- setRowExpand
18689
+ setRowExpand,
18690
+ clearSelection,
18691
+ toggleAllSelection,
18692
+ toggleRowSelection
18533
18693
  });
18534
18694
  const tableBodyClass = computed(() => __spreadProps(__spreadValues({}, contentClass), {
18535
18695
  "__is-empty": !pageData.length
@@ -20262,28 +20422,38 @@ const InfoBox = (config) => {
20262
20422
  update
20263
20423
  });
20264
20424
  const getContent = () => {
20265
- if (!modalFuncProps.value.subTitle) {
20266
- return "";
20425
+ const children = [];
20426
+ const subTitleBox = [];
20427
+ if (modalFuncProps.value.subTitle) {
20428
+ switch (typeof modalFuncProps.value.subTitle) {
20429
+ case "string":
20430
+ children.push(modalFuncProps.value.subTitle);
20431
+ break;
20432
+ case "function":
20433
+ children.push(modalFuncProps.value.subTitle());
20434
+ break;
20435
+ default:
20436
+ children.push(modalFuncProps.value.subTitle);
20437
+ break;
20438
+ }
20267
20439
  }
20268
- switch (typeof modalFuncProps.value.subTitle) {
20269
- case "function":
20270
- return modalFuncProps.value.subTitle();
20271
- default:
20272
- case "string":
20273
- return modalFuncProps.value.subTitle;
20440
+ if (children.length) {
20441
+ subTitleBox.push(h$1("div", {
20442
+ class: "bk-info-sub-title",
20443
+ style: `text-Align:${modalFuncProps.value.contentAlign || "center"}`
20444
+ }, children));
20274
20445
  }
20446
+ return subTitleBox;
20275
20447
  };
20276
20448
  return () => createVNode(Dialog, __spreadProps(__spreadValues({
20449
+ class: "bk-info-wrapper",
20277
20450
  headerAlign: "center",
20278
20451
  footerAlign: "center"
20279
20452
  }, modalFuncProps.value), {
20280
20453
  isShow: isShow.value,
20281
20454
  onClosed,
20282
20455
  onConfirm
20283
- }), [h$1("div", {
20284
- class: "bk-info-sub-title",
20285
- style: `text-Align:${modalFuncProps.value.contentAlign || "center"}`
20286
- }, getContent())]);
20456
+ }), getContent());
20287
20457
  }
20288
20458
  });
20289
20459
  const app = createApp(dialog2).mount(container2);