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

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
@@ -33,7 +33,7 @@ var __publicField = (obj, key2, value) => {
33
33
  __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
34
34
  return value;
35
35
  };
36
- import { inject, createVNode, h as h$1, mergeProps, defineComponent, reactive, ref, computed, watch, onMounted, onBeforeUnmount, getCurrentInstance, nextTick, Transition, provide, createTextVNode, isVNode, withDirectives, vShow, renderSlot, Fragment, toRefs, createApp, onUnmounted, Teleport, resolveDirective, customRef, onBeforeMount, toRef, vModelText, watchEffect, onUpdated, render as render$1, shallowRef, toRaw, withModifiers, TransitionGroup } from "vue";
36
+ import { inject, createVNode, h as h$1, mergeProps, defineComponent, reactive, ref, computed, watch, onMounted, onBeforeUnmount, getCurrentInstance, nextTick, Transition, provide, createTextVNode, isVNode, withDirectives, vShow, renderSlot, Fragment, toRefs, createApp, Teleport, resolveDirective, customRef, onBeforeMount, toRef, vModelText, unref, watchEffect, onUpdated, render as render$1, onUnmounted, shallowRef, toRaw, withModifiers, TransitionGroup } from "vue";
37
37
  var reset = "";
38
38
  var alert = "";
39
39
  var affix = "";
@@ -13046,7 +13046,7 @@ var useFloating = (props2, ctx, refReference, refContent, refArrow, refRoot) =>
13046
13046
  elArrow
13047
13047
  } = resolvePopElements();
13048
13048
  const targetEl = virtualEl || elReference;
13049
- if (!targetEl)
13049
+ if (!targetEl || !elContent)
13050
13050
  return;
13051
13051
  const options = resolvePopOptions(elArrow, props3);
13052
13052
  computePosition(targetEl, elContent, options).then(({
@@ -13297,9 +13297,6 @@ var usePopoverInit = (props2, ctx, refReference, refContent, refArrow, refRoot)
13297
13297
  const { getPrefixId, resetFullscreenElementTag } = usePopperId(props2, "#");
13298
13298
  const boundary = ref();
13299
13299
  const beforeInstanceUnmount = () => {
13300
- if (typeof cleanup === "function") {
13301
- cleanup();
13302
- }
13303
13300
  removeEventListener2();
13304
13301
  };
13305
13302
  const handleFullscreenChange = () => {
@@ -13401,7 +13398,7 @@ var Component$p = defineComponent({
13401
13398
  });
13402
13399
  updateBoundary();
13403
13400
  onMounted(onMountedFn);
13404
- onUnmounted(onUnmountedFn);
13401
+ onBeforeUnmount(onUnmountedFn);
13405
13402
  const transBoundary = computed(() => (isFullscreen.value || !disableTeleport) && typeof boundary.value === "string");
13406
13403
  const show2 = () => {
13407
13404
  showFn();
@@ -16068,6 +16065,7 @@ const DEFAULT_SIZE_LIST = [
16068
16065
  { value: "medium", label: "\u4E2D", height: SETTING_SIZE.medium },
16069
16066
  { value: "large", label: "\u5927", height: SETTING_SIZE.large }
16070
16067
  ];
16068
+ const PROVIDE_KEY_INIT_COL = "InitColumns";
16071
16069
  var SortScope = /* @__PURE__ */ ((SortScope2) => {
16072
16070
  SortScope2["CURRENT"] = "current";
16073
16071
  SortScope2["ALL"] = "all";
@@ -16079,6 +16077,7 @@ const IColumnType = {
16079
16077
  render: PropTypes.oneOfType([PropTypes.func.def(() => ""), PropTypes.string.def("")]),
16080
16078
  width: PropTypes.oneOfType([PropTypes.number.def(void 0), PropTypes.string.def("auto")]),
16081
16079
  minWidth: PropTypes.oneOfType([PropTypes.number.def(void 0), PropTypes.string.def("auto")]).def(),
16080
+ columnKey: PropTypes.string.def(""),
16082
16081
  showOverflowTooltip: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
16083
16082
  content: PropTypes.string.def(""),
16084
16083
  disabled: PropTypes.bool.def(false),
@@ -16160,6 +16159,34 @@ const tableProps = {
16160
16159
  PropTypes.func
16161
16160
  ]).def(TABLE_ROW_ATTRIBUTE.ROW_INDEX)
16162
16161
  };
16162
+ var Column = defineComponent({
16163
+ name: "TableColumn",
16164
+ props: __spreadProps(__spreadValues({}, IColumnType), {
16165
+ prop: PropTypes.oneOfType([PropTypes.func.def(() => ""), PropTypes.string.def("")])
16166
+ }),
16167
+ setup(props2, {
16168
+ slots
16169
+ }) {
16170
+ const initColumns = inject(PROVIDE_KEY_INIT_COL, (_column) => {
16171
+ }, false);
16172
+ onMounted(() => {
16173
+ const column = reactive(__spreadProps(__spreadValues({}, props2), {
16174
+ field: props2.prop || props2.field
16175
+ }));
16176
+ initColumns(column);
16177
+ column.render = slots.default ? (args) => {
16178
+ var _a;
16179
+ return (_a = slots.default) == null ? void 0 : _a.call(slots, args);
16180
+ } : void 0;
16181
+ });
16182
+ return () => {
16183
+ var _a;
16184
+ return createVNode(Fragment, null, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
16185
+ data: ""
16186
+ })]);
16187
+ };
16188
+ }
16189
+ });
16163
16190
  const resolvePaginationOption = (propPagination, defVal) => {
16164
16191
  if (!!propPagination) {
16165
16192
  if (typeof propPagination === "object") {
@@ -17398,10 +17425,10 @@ var Settings = defineComponent({
17398
17425
  theme
17399
17426
  }), {
17400
17427
  default: () => createVNode("span", {
17401
- "class": "table-head-settings"
17402
- }, [createVNode(cogShape, {
17403
- "style": "color: #c4c6cc;",
17428
+ "class": "table-head-settings",
17404
17429
  "onClick": handleSettingClick
17430
+ }, [createVNode(cogShape, {
17431
+ "style": "color: #c4c6cc;"
17405
17432
  }, null)]),
17406
17433
  content: () => {
17407
17434
  let _slot2;
@@ -17597,7 +17624,7 @@ class TableRender {
17597
17624
  return [this.props.settings ? createVNode(Settings, {
17598
17625
  "class": "table-head-settings",
17599
17626
  "settings": this.reactiveProp.settings,
17600
- "columns": this.props.columns,
17627
+ "columns": this.colgroups,
17601
17628
  "rowHeight": this.props.rowHeight,
17602
17629
  "onChange": handleSettingsChanged
17603
17630
  }, null) : "", createVNode("table", {
@@ -17919,6 +17946,37 @@ class TableRender {
17919
17946
  return this.reactiveProp.setting;
17920
17947
  }
17921
17948
  }
17949
+ var useColumn = (props2, targetColumns) => {
17950
+ const initColumns = (column) => {
17951
+ let resolveColumns = [];
17952
+ if (!Array.isArray(column)) {
17953
+ resolveColumns = [column];
17954
+ } else {
17955
+ resolveColumns = column;
17956
+ }
17957
+ resolveColumns.forEach((col) => {
17958
+ const matchCol = targetColumns.find((c2) => c2.label === col.label && c2.field === col.field);
17959
+ if (!matchCol) {
17960
+ const unrefCol = unref(col);
17961
+ targetColumns.push(unrefCol);
17962
+ }
17963
+ });
17964
+ };
17965
+ const getColumns = () => {
17966
+ var _a;
17967
+ if (targetColumns == null ? void 0 : targetColumns.length) {
17968
+ return targetColumns;
17969
+ }
17970
+ if ((_a = props2.columns) == null ? void 0 : _a.length) {
17971
+ return props2.columns;
17972
+ }
17973
+ return [];
17974
+ };
17975
+ return {
17976
+ initColumns,
17977
+ getColumns
17978
+ };
17979
+ };
17922
17980
  const resolveActiveColumns = (props2) => {
17923
17981
  if (props2.columnPick !== "disabled") {
17924
17982
  if (props2.columnPick === "multi") {
@@ -17928,15 +17986,18 @@ const resolveActiveColumns = (props2) => {
17928
17986
  }
17929
17987
  return [];
17930
17988
  };
17931
- var useActiveColumns = (props2) => {
17989
+ var useActiveColumns = (props2, targetColumns) => {
17932
17990
  let activeColumns = reactive([]);
17991
+ const {
17992
+ getColumns
17993
+ } = useColumn(props2, targetColumns);
17933
17994
  if (props2.columnPick === "disabled") {
17934
17995
  return {
17935
17996
  activeColumns
17936
17997
  };
17937
17998
  }
17938
17999
  const activeCols = reactive(resolveActiveColumns(props2));
17939
- const getActiveColumns = () => (props2.columns || []).map((_column, index) => ({
18000
+ const getActiveColumns = () => getColumns().map((_column, index) => ({
17940
18001
  index,
17941
18002
  active: activeCols.some((colIndex) => colIndex === index),
17942
18003
  _column
@@ -18080,7 +18141,8 @@ var useColumnResize = (colgroups, immediate = true) => {
18080
18141
  dragOffsetXStyle
18081
18142
  };
18082
18143
  };
18083
- const useClass = (props2, root, reactiveProp, pageData) => {
18144
+ const useClass = (props2, targetColumns, root, reactiveProp, pageData) => {
18145
+ const { getColumns } = useColumn(props2, targetColumns);
18084
18146
  const autoHeight = ref(200);
18085
18147
  const hasScrollY = ref(void 0);
18086
18148
  const hasFooter = computed(() => props2.pagination && props2.data.length);
@@ -18107,8 +18169,9 @@ const useClass = (props2, root, reactiveProp, pageData) => {
18107
18169
  ["is-hidden"]: !props2.pagination || !props2.data.length
18108
18170
  }));
18109
18171
  const resolveWidth2 = () => {
18110
- if (props2.columns.every((col) => /^\d+\.?\d*(px)?$/ig.test(`${col.width}`))) {
18111
- const rectWidth = props2.columns.reduce((width, col) => width + Number(`${col.width}`.replace(/px/ig, "")), 0);
18172
+ const columns = getColumns();
18173
+ if (columns.every((col) => /^\d+\.?\d*(px)?$/ig.test(`${col.width}`))) {
18174
+ const rectWidth = columns.reduce((width, col) => width + Number(`${col.width}`.replace(/px/ig, "")), 0);
18112
18175
  const offset2 = hasScrollY.value ? SCROLLY_WIDTH : 0;
18113
18176
  return `${rectWidth + offset2}px`;
18114
18177
  }
@@ -18133,7 +18196,12 @@ const useClass = (props2, root, reactiveProp, pageData) => {
18133
18196
  }
18134
18197
  return defaultValue;
18135
18198
  };
18136
- const contentStyle = reactive({});
18199
+ const contentStyle = reactive({
18200
+ display: "",
18201
+ "min-height": "",
18202
+ height: "",
18203
+ maxHeight: ""
18204
+ });
18137
18205
  const getHeadHeight = () => props2.showHead ? resolvePropHeight(props2.headHeight, LINE_HEIGHT) : 0;
18138
18206
  const resolveContentStyle = () => {
18139
18207
  const resolveHeight = resolvePropHeight(props2.height, autoHeight.value);
@@ -18193,19 +18261,20 @@ const useClass = (props2, root, reactiveProp, pageData) => {
18193
18261
  hasScrollY
18194
18262
  };
18195
18263
  };
18196
- const useInit = (props2) => {
18264
+ const useInit = (props2, targetColumns) => {
18197
18265
  var _a, _b;
18198
18266
  const colgroups = reactive([]);
18267
+ const { getColumns } = useColumn(props2, targetColumns);
18199
18268
  const updateColGroups = () => {
18200
- colgroups.splice(0, colgroups.length, ...(props2.columns || []).map((col) => __spreadProps(__spreadValues({}, col), {
18269
+ colgroups.splice(0, colgroups.length, ...getColumns().map((col) => __spreadProps(__spreadValues({}, col), {
18201
18270
  calcWidth: null,
18202
18271
  resizeWidth: null,
18203
18272
  listeners: /* @__PURE__ */ new Map()
18204
18273
  })));
18205
18274
  };
18206
18275
  const { dragOffsetXStyle, dragOffsetX, resetResizeEvents, registerResizeEvent } = useColumnResize(colgroups, true);
18207
- const { activeColumns } = useActiveColumns(props2);
18208
- watch(() => props2.columns, () => {
18276
+ const { activeColumns } = useActiveColumns(props2, targetColumns);
18277
+ watch(() => [props2.columns, targetColumns], () => {
18209
18278
  updateColGroups();
18210
18279
  resetResizeEvents();
18211
18280
  registerResizeEvent();
@@ -18280,6 +18349,11 @@ var Component$d = defineComponent({
18280
18349
  let activeSortColumn = null;
18281
18350
  let columnFilterFn = null;
18282
18351
  let observerIns = null;
18352
+ const targetColumns = reactive([]);
18353
+ const {
18354
+ initColumns
18355
+ } = useColumn(props2, targetColumns);
18356
+ provide(PROVIDE_KEY_INIT_COL, initColumns);
18283
18357
  const root = ref();
18284
18358
  const refVirtualRender = ref();
18285
18359
  const tableOffsetRight = ref(0);
@@ -18293,7 +18367,7 @@ var Component$d = defineComponent({
18293
18367
  setRowExpand,
18294
18368
  initIndexData,
18295
18369
  fixedWrapperClass
18296
- } = useInit(props2);
18370
+ } = useInit(props2, targetColumns);
18297
18371
  const {
18298
18372
  pageData,
18299
18373
  localPagination,
@@ -18312,7 +18386,7 @@ var Component$d = defineComponent({
18312
18386
  resetTableHeight,
18313
18387
  getColumnsWidthOffsetWidth,
18314
18388
  hasFooter
18315
- } = useClass(props2, root, reactiveSchema, pageData);
18389
+ } = useClass(props2, targetColumns, root, reactiveSchema, pageData);
18316
18390
  const tableRender = new TableRender(props2, ctx, reactiveSchema, colgroups);
18317
18391
  const updateOffsetRight = () => {
18318
18392
  const $tableContent = root.value.querySelector(".bk-table-body-content");
@@ -18323,7 +18397,7 @@ var Component$d = defineComponent({
18323
18397
  tableOffsetRight.value = $tableScrollWidth - $contentWidth;
18324
18398
  }
18325
18399
  };
18326
- watch(() => [props2.data, props2.pagination], () => {
18400
+ watch(() => [props2.data, props2.pagination, props2.height, props2.maxHeight, props2.minHeight], () => {
18327
18401
  initIndexData(props2.reserveExpand);
18328
18402
  watchEffectFn(columnFilterFn, columnSortFn, activeSortColumn);
18329
18403
  nextTick(() => {
@@ -18479,6 +18553,12 @@ var Component$d = defineComponent({
18479
18553
  [resolveClassName("fixed-bottom-border")]: true,
18480
18554
  "_is-empty": !props2.data.length
18481
18555
  };
18556
+ const columnGhostStyle = {
18557
+ zIndex: -1,
18558
+ width: 0,
18559
+ height: 0,
18560
+ display: "none"
18561
+ };
18482
18562
  const {
18483
18563
  renderScrollLoading
18484
18564
  } = useScrollLoading(props2, ctx);
@@ -18486,48 +18566,56 @@ var Component$d = defineComponent({
18486
18566
  scrollXName: "",
18487
18567
  scrollYName: ""
18488
18568
  };
18489
- return () => createVNode("div", {
18490
- "class": tableClass.value,
18491
- "style": wrapperStyle.value,
18492
- "ref": root
18493
- }, [
18494
- createVNode("div", {
18495
- "class": headClass,
18496
- "style": headStyle.value
18497
- }, [tableRender.renderTableHeadSchema()]),
18498
- createVNode(BkVirtualRender, mergeProps({
18499
- "ref": refVirtualRender,
18500
- "lineHeight": tableRender.getRowHeight,
18501
- "class": tableBodyClass.value,
18502
- "style": contentStyle,
18503
- "list": pageData
18504
- }, scrollClass, {
18505
- "contentClassName": tableBodyContentClass,
18506
- "onContentScroll": handleScrollChanged,
18507
- "throttleDelay": 0,
18508
- "scrollEvent": true,
18509
- "enabled": props2.virtualEnabled
18510
- }), {
18511
- default: (scope) => tableRender.renderTableBodySchema(scope.data || props2.data),
18512
- afterSection: () => createVNode("div", {
18513
- "class": fixedBottomBorder
18514
- }, null)
18515
- }),
18516
- createVNode("div", {
18517
- "class": fixedWrapperClass
18518
- }, [renderFixedColumns(reactiveSchema.scrollTranslateX, tableOffsetRight.value), createVNode("div", {
18519
- "class": resizeColumnClass,
18520
- "style": resizeColumnStyle.value
18521
- }, null), createVNode("div", {
18522
- "class": loadingRowClass
18523
- }, [renderScrollLoading()])]),
18524
- createVNode("div", {
18525
- "class": footerClass.value
18526
- }, [hasFooter.value && tableRender.renderTableFooter(localPagination.value)])
18527
- ]);
18569
+ return () => {
18570
+ var _a, _b;
18571
+ return createVNode("div", {
18572
+ "class": tableClass.value,
18573
+ "style": wrapperStyle.value,
18574
+ "ref": root
18575
+ }, [
18576
+ createVNode("div", {
18577
+ "class": headClass,
18578
+ "style": headStyle.value
18579
+ }, [tableRender.renderTableHeadSchema()]),
18580
+ createVNode(BkVirtualRender, mergeProps({
18581
+ "ref": refVirtualRender,
18582
+ "lineHeight": tableRender.getRowHeight,
18583
+ "class": tableBodyClass.value,
18584
+ "style": contentStyle,
18585
+ "list": pageData
18586
+ }, scrollClass, {
18587
+ "contentClassName": tableBodyContentClass,
18588
+ "onContentScroll": handleScrollChanged,
18589
+ "throttleDelay": 0,
18590
+ "scrollEvent": true,
18591
+ "enabled": props2.virtualEnabled
18592
+ }), {
18593
+ default: (scope) => tableRender.renderTableBodySchema(scope.data || props2.data),
18594
+ afterSection: () => createVNode("div", {
18595
+ "class": fixedBottomBorder
18596
+ }, null)
18597
+ }),
18598
+ createVNode("div", {
18599
+ "class": fixedWrapperClass
18600
+ }, [renderFixedColumns(reactiveSchema.scrollTranslateX, tableOffsetRight.value), createVNode("div", {
18601
+ "class": resizeColumnClass,
18602
+ "style": resizeColumnStyle.value
18603
+ }, null), createVNode("div", {
18604
+ "class": loadingRowClass
18605
+ }, [renderScrollLoading()])]),
18606
+ createVNode("div", {
18607
+ "class": footerClass.value
18608
+ }, [hasFooter.value && tableRender.renderTableFooter(localPagination.value)]),
18609
+ createVNode("div", {
18610
+ "style": columnGhostStyle
18611
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])
18612
+ ]);
18613
+ };
18528
18614
  }
18529
18615
  });
18530
18616
  const BkTable = withInstall(Component$d);
18617
+ withInstall(Column);
18618
+ const BkTableColumn = withInstall(Column);
18531
18619
  const INPUT_MIN_WIDTH = 12;
18532
18620
  function usePage(pageSize) {
18533
18621
  const state = reactive({
@@ -35740,6 +35828,7 @@ var components = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
35740
35828
  Steps: BkSteps$2,
35741
35829
  Switcher: BkSwitcher,
35742
35830
  Table: BkTable,
35831
+ TableColumn: BkTableColumn,
35743
35832
  Tag: BkTag,
35744
35833
  TagInput,
35745
35834
  Divider: BkDivider,
@@ -35785,4 +35874,4 @@ var preset = {
35785
35874
  install: createInstall(),
35786
35875
  version: "0.0.1"
35787
35876
  };
35788
- export { createPopoverComponent as $bkPopover, BkAffix as Affix, BkAlert as Alert, BkAnimateNumber as AnimateNumber, BkBacktop as Backtop, BkBadge as Badge, BkBreadcrumb as Breadcrumb, BkButton as Button, BkCard as Card, BkCascader as Cascader, BkCheckbox as Checkbox, BkCodeDiff as CodeDiff, BkCollapse as Collapse, BkColorPicker as ColorPicker, BkContainer as Container, BkDatePicker as DatePicker, BkDialog as Dialog, BkDivider as Divider, BkDropdown as Dropdown, BkException as Exception, BkFixedNavbar as FixedNavbar, BkForm as Form, InfoBox, BkInput as Input, BkLink as Link, BkLoading as Loading, BkMenu as Menu, Message, BkModal as Modal, Navigation, Notify, BkPagination as Pagination, BkPopover as Popover, BkPopover2 as Popover2, BkSteps as Process, BkProgress as Progress, BkRadio as Radio, BkRate as Rate, BkResizeLayout as ResizeLayout, BkSelect as Select, BkSideslider as Sideslider, Slider, BkSteps$2 as Steps, BkSwiper as Swiper, BkSwitcher as Switcher, BkTab as Tab, BkTable as Table, BkTag as Tag, TagInput, BkSteps$1 as TimeLine, BkTimePicker as TimePicker, Transfer, BkTree as Tree, Upload, BkVirtualRender as VirtualRender, ellipsis as bkEllipsis, createInstance as bkEllipsisInstance, tooltips as bkTooltips, ClickOutside as clickoutside, BkContainer as containerProps, preset as default, mousewheel };
35877
+ export { createPopoverComponent as $bkPopover, BkAffix as Affix, BkAlert as Alert, BkAnimateNumber as AnimateNumber, BkBacktop as Backtop, BkBadge as Badge, BkBreadcrumb as Breadcrumb, BkButton as Button, BkCard as Card, BkCascader as Cascader, BkCheckbox as Checkbox, BkCodeDiff as CodeDiff, BkCollapse as Collapse, BkColorPicker as ColorPicker, BkContainer as Container, BkDatePicker as DatePicker, BkDialog as Dialog, BkDivider as Divider, BkDropdown as Dropdown, BkException as Exception, BkFixedNavbar as FixedNavbar, BkForm as Form, InfoBox, BkInput as Input, BkLink as Link, BkLoading as Loading, BkMenu as Menu, Message, BkModal as Modal, Navigation, Notify, BkPagination as Pagination, BkPopover as Popover, BkPopover2 as Popover2, BkSteps as Process, BkProgress as Progress, BkRadio as Radio, BkRate as Rate, BkResizeLayout as ResizeLayout, BkSelect as Select, BkSideslider as Sideslider, Slider, BkSteps$2 as Steps, BkSwiper as Swiper, BkSwitcher as Switcher, BkTab as Tab, BkTable as Table, BkTableColumn as TableColumn, BkTag as Tag, TagInput, BkSteps$1 as TimeLine, BkTimePicker as TimePicker, Transfer, BkTree as Tree, Upload, BkVirtualRender as VirtualRender, ellipsis as bkEllipsis, createInstance as bkEllipsisInstance, tooltips as bkTooltips, ClickOutside as clickoutside, BkContainer as containerProps, preset as default, mousewheel };