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

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, onUnmounted, Teleport, resolveDirective, customRef, onBeforeMount, toRef, vModelText, unref, watchEffect, onUpdated, render as render$1, shallowRef, toRaw, withModifiers, TransitionGroup } from "vue";
37
37
  var reset = "";
38
38
  var alert = "";
39
39
  var affix = "";
@@ -16068,6 +16068,7 @@ const DEFAULT_SIZE_LIST = [
16068
16068
  { value: "medium", label: "\u4E2D", height: SETTING_SIZE.medium },
16069
16069
  { value: "large", label: "\u5927", height: SETTING_SIZE.large }
16070
16070
  ];
16071
+ const PROVIDE_KEY_INIT_COL = "InitColumns";
16071
16072
  var SortScope = /* @__PURE__ */ ((SortScope2) => {
16072
16073
  SortScope2["CURRENT"] = "current";
16073
16074
  SortScope2["ALL"] = "all";
@@ -16079,6 +16080,7 @@ const IColumnType = {
16079
16080
  render: PropTypes.oneOfType([PropTypes.func.def(() => ""), PropTypes.string.def("")]),
16080
16081
  width: PropTypes.oneOfType([PropTypes.number.def(void 0), PropTypes.string.def("auto")]),
16081
16082
  minWidth: PropTypes.oneOfType([PropTypes.number.def(void 0), PropTypes.string.def("auto")]).def(),
16083
+ columnKey: PropTypes.string.def(""),
16082
16084
  showOverflowTooltip: PropTypes.oneOfType([PropTypes.bool, PropTypes.shape({
16083
16085
  content: PropTypes.string.def(""),
16084
16086
  disabled: PropTypes.bool.def(false),
@@ -16160,6 +16162,34 @@ const tableProps = {
16160
16162
  PropTypes.func
16161
16163
  ]).def(TABLE_ROW_ATTRIBUTE.ROW_INDEX)
16162
16164
  };
16165
+ var Column = defineComponent({
16166
+ name: "TableColumn",
16167
+ props: __spreadProps(__spreadValues({}, IColumnType), {
16168
+ prop: PropTypes.oneOfType([PropTypes.func.def(() => ""), PropTypes.string.def("")])
16169
+ }),
16170
+ setup(props2, {
16171
+ slots
16172
+ }) {
16173
+ const initColumns = inject(PROVIDE_KEY_INIT_COL, (_column) => {
16174
+ }, false);
16175
+ onMounted(() => {
16176
+ const column = reactive(__spreadProps(__spreadValues({}, props2), {
16177
+ field: props2.prop || props2.field
16178
+ }));
16179
+ initColumns(column);
16180
+ column.render = slots.default ? (args) => {
16181
+ var _a;
16182
+ return (_a = slots.default) == null ? void 0 : _a.call(slots, args);
16183
+ } : void 0;
16184
+ });
16185
+ return () => {
16186
+ var _a;
16187
+ return createVNode(Fragment, null, [(_a = slots.default) == null ? void 0 : _a.call(slots, {
16188
+ data: ""
16189
+ })]);
16190
+ };
16191
+ }
16192
+ });
16163
16193
  const resolvePaginationOption = (propPagination, defVal) => {
16164
16194
  if (!!propPagination) {
16165
16195
  if (typeof propPagination === "object") {
@@ -17398,10 +17428,10 @@ var Settings = defineComponent({
17398
17428
  theme
17399
17429
  }), {
17400
17430
  default: () => createVNode("span", {
17401
- "class": "table-head-settings"
17402
- }, [createVNode(cogShape, {
17403
- "style": "color: #c4c6cc;",
17431
+ "class": "table-head-settings",
17404
17432
  "onClick": handleSettingClick
17433
+ }, [createVNode(cogShape, {
17434
+ "style": "color: #c4c6cc;"
17405
17435
  }, null)]),
17406
17436
  content: () => {
17407
17437
  let _slot2;
@@ -17597,7 +17627,7 @@ class TableRender {
17597
17627
  return [this.props.settings ? createVNode(Settings, {
17598
17628
  "class": "table-head-settings",
17599
17629
  "settings": this.reactiveProp.settings,
17600
- "columns": this.props.columns,
17630
+ "columns": this.colgroups,
17601
17631
  "rowHeight": this.props.rowHeight,
17602
17632
  "onChange": handleSettingsChanged
17603
17633
  }, null) : "", createVNode("table", {
@@ -17919,6 +17949,37 @@ class TableRender {
17919
17949
  return this.reactiveProp.setting;
17920
17950
  }
17921
17951
  }
17952
+ var useColumn = (props2, targetColumns) => {
17953
+ const initColumns = (column) => {
17954
+ let resolveColumns = [];
17955
+ if (!Array.isArray(column)) {
17956
+ resolveColumns = [column];
17957
+ } else {
17958
+ resolveColumns = column;
17959
+ }
17960
+ resolveColumns.forEach((col) => {
17961
+ const matchCol = targetColumns.find((c2) => c2.label === col.label && c2.field === col.field);
17962
+ if (!matchCol) {
17963
+ const unrefCol = unref(col);
17964
+ targetColumns.push(unrefCol);
17965
+ }
17966
+ });
17967
+ };
17968
+ const getColumns = () => {
17969
+ var _a;
17970
+ if (targetColumns == null ? void 0 : targetColumns.length) {
17971
+ return targetColumns;
17972
+ }
17973
+ if ((_a = props2.columns) == null ? void 0 : _a.length) {
17974
+ return props2.columns;
17975
+ }
17976
+ return [];
17977
+ };
17978
+ return {
17979
+ initColumns,
17980
+ getColumns
17981
+ };
17982
+ };
17922
17983
  const resolveActiveColumns = (props2) => {
17923
17984
  if (props2.columnPick !== "disabled") {
17924
17985
  if (props2.columnPick === "multi") {
@@ -17928,15 +17989,18 @@ const resolveActiveColumns = (props2) => {
17928
17989
  }
17929
17990
  return [];
17930
17991
  };
17931
- var useActiveColumns = (props2) => {
17992
+ var useActiveColumns = (props2, targetColumns) => {
17932
17993
  let activeColumns = reactive([]);
17994
+ const {
17995
+ getColumns
17996
+ } = useColumn(props2, targetColumns);
17933
17997
  if (props2.columnPick === "disabled") {
17934
17998
  return {
17935
17999
  activeColumns
17936
18000
  };
17937
18001
  }
17938
18002
  const activeCols = reactive(resolveActiveColumns(props2));
17939
- const getActiveColumns = () => (props2.columns || []).map((_column, index) => ({
18003
+ const getActiveColumns = () => getColumns().map((_column, index) => ({
17940
18004
  index,
17941
18005
  active: activeCols.some((colIndex) => colIndex === index),
17942
18006
  _column
@@ -18080,7 +18144,8 @@ var useColumnResize = (colgroups, immediate = true) => {
18080
18144
  dragOffsetXStyle
18081
18145
  };
18082
18146
  };
18083
- const useClass = (props2, root, reactiveProp, pageData) => {
18147
+ const useClass = (props2, targetColumns, root, reactiveProp, pageData) => {
18148
+ const { getColumns } = useColumn(props2, targetColumns);
18084
18149
  const autoHeight = ref(200);
18085
18150
  const hasScrollY = ref(void 0);
18086
18151
  const hasFooter = computed(() => props2.pagination && props2.data.length);
@@ -18107,8 +18172,9 @@ const useClass = (props2, root, reactiveProp, pageData) => {
18107
18172
  ["is-hidden"]: !props2.pagination || !props2.data.length
18108
18173
  }));
18109
18174
  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);
18175
+ const columns = getColumns();
18176
+ if (columns.every((col) => /^\d+\.?\d*(px)?$/ig.test(`${col.width}`))) {
18177
+ const rectWidth = columns.reduce((width, col) => width + Number(`${col.width}`.replace(/px/ig, "")), 0);
18112
18178
  const offset2 = hasScrollY.value ? SCROLLY_WIDTH : 0;
18113
18179
  return `${rectWidth + offset2}px`;
18114
18180
  }
@@ -18193,19 +18259,20 @@ const useClass = (props2, root, reactiveProp, pageData) => {
18193
18259
  hasScrollY
18194
18260
  };
18195
18261
  };
18196
- const useInit = (props2) => {
18262
+ const useInit = (props2, targetColumns) => {
18197
18263
  var _a, _b;
18198
18264
  const colgroups = reactive([]);
18265
+ const { getColumns } = useColumn(props2, targetColumns);
18199
18266
  const updateColGroups = () => {
18200
- colgroups.splice(0, colgroups.length, ...(props2.columns || []).map((col) => __spreadProps(__spreadValues({}, col), {
18267
+ colgroups.splice(0, colgroups.length, ...getColumns().map((col) => __spreadProps(__spreadValues({}, col), {
18201
18268
  calcWidth: null,
18202
18269
  resizeWidth: null,
18203
18270
  listeners: /* @__PURE__ */ new Map()
18204
18271
  })));
18205
18272
  };
18206
18273
  const { dragOffsetXStyle, dragOffsetX, resetResizeEvents, registerResizeEvent } = useColumnResize(colgroups, true);
18207
- const { activeColumns } = useActiveColumns(props2);
18208
- watch(() => props2.columns, () => {
18274
+ const { activeColumns } = useActiveColumns(props2, targetColumns);
18275
+ watch(() => [props2.columns, targetColumns], () => {
18209
18276
  updateColGroups();
18210
18277
  resetResizeEvents();
18211
18278
  registerResizeEvent();
@@ -18280,6 +18347,11 @@ var Component$d = defineComponent({
18280
18347
  let activeSortColumn = null;
18281
18348
  let columnFilterFn = null;
18282
18349
  let observerIns = null;
18350
+ const targetColumns = reactive([]);
18351
+ const {
18352
+ initColumns
18353
+ } = useColumn(props2, targetColumns);
18354
+ provide(PROVIDE_KEY_INIT_COL, initColumns);
18283
18355
  const root = ref();
18284
18356
  const refVirtualRender = ref();
18285
18357
  const tableOffsetRight = ref(0);
@@ -18293,7 +18365,7 @@ var Component$d = defineComponent({
18293
18365
  setRowExpand,
18294
18366
  initIndexData,
18295
18367
  fixedWrapperClass
18296
- } = useInit(props2);
18368
+ } = useInit(props2, targetColumns);
18297
18369
  const {
18298
18370
  pageData,
18299
18371
  localPagination,
@@ -18312,7 +18384,7 @@ var Component$d = defineComponent({
18312
18384
  resetTableHeight,
18313
18385
  getColumnsWidthOffsetWidth,
18314
18386
  hasFooter
18315
- } = useClass(props2, root, reactiveSchema, pageData);
18387
+ } = useClass(props2, targetColumns, root, reactiveSchema, pageData);
18316
18388
  const tableRender = new TableRender(props2, ctx, reactiveSchema, colgroups);
18317
18389
  const updateOffsetRight = () => {
18318
18390
  const $tableContent = root.value.querySelector(".bk-table-body-content");
@@ -18479,6 +18551,12 @@ var Component$d = defineComponent({
18479
18551
  [resolveClassName("fixed-bottom-border")]: true,
18480
18552
  "_is-empty": !props2.data.length
18481
18553
  };
18554
+ const columnGhostStyle = {
18555
+ zIndex: -1,
18556
+ width: 0,
18557
+ height: 0,
18558
+ display: "none"
18559
+ };
18482
18560
  const {
18483
18561
  renderScrollLoading
18484
18562
  } = useScrollLoading(props2, ctx);
@@ -18486,48 +18564,56 @@ var Component$d = defineComponent({
18486
18564
  scrollXName: "",
18487
18565
  scrollYName: ""
18488
18566
  };
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
- ]);
18567
+ return () => {
18568
+ var _a, _b;
18569
+ return createVNode("div", {
18570
+ "class": tableClass.value,
18571
+ "style": wrapperStyle.value,
18572
+ "ref": root
18573
+ }, [
18574
+ createVNode("div", {
18575
+ "class": headClass,
18576
+ "style": headStyle.value
18577
+ }, [tableRender.renderTableHeadSchema()]),
18578
+ createVNode(BkVirtualRender, mergeProps({
18579
+ "ref": refVirtualRender,
18580
+ "lineHeight": tableRender.getRowHeight,
18581
+ "class": tableBodyClass.value,
18582
+ "style": contentStyle,
18583
+ "list": pageData
18584
+ }, scrollClass, {
18585
+ "contentClassName": tableBodyContentClass,
18586
+ "onContentScroll": handleScrollChanged,
18587
+ "throttleDelay": 0,
18588
+ "scrollEvent": true,
18589
+ "enabled": props2.virtualEnabled
18590
+ }), {
18591
+ default: (scope) => tableRender.renderTableBodySchema(scope.data || props2.data),
18592
+ afterSection: () => createVNode("div", {
18593
+ "class": fixedBottomBorder
18594
+ }, null)
18595
+ }),
18596
+ createVNode("div", {
18597
+ "class": fixedWrapperClass
18598
+ }, [renderFixedColumns(reactiveSchema.scrollTranslateX, tableOffsetRight.value), createVNode("div", {
18599
+ "class": resizeColumnClass,
18600
+ "style": resizeColumnStyle.value
18601
+ }, null), createVNode("div", {
18602
+ "class": loadingRowClass
18603
+ }, [renderScrollLoading()])]),
18604
+ createVNode("div", {
18605
+ "class": footerClass.value
18606
+ }, [hasFooter.value && tableRender.renderTableFooter(localPagination.value)]),
18607
+ createVNode("div", {
18608
+ "style": columnGhostStyle
18609
+ }, [(_b = (_a = ctx.slots).default) == null ? void 0 : _b.call(_a)])
18610
+ ]);
18611
+ };
18528
18612
  }
18529
18613
  });
18530
18614
  const BkTable = withInstall(Component$d);
18615
+ withInstall(Column);
18616
+ const BkTableColumn = withInstall(Column);
18531
18617
  const INPUT_MIN_WIDTH = 12;
18532
18618
  function usePage(pageSize) {
18533
18619
  const state = reactive({
@@ -35740,6 +35826,7 @@ var components = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProp
35740
35826
  Steps: BkSteps$2,
35741
35827
  Switcher: BkSwitcher,
35742
35828
  Table: BkTable,
35829
+ TableColumn: BkTableColumn,
35743
35830
  Tag: BkTag,
35744
35831
  TagInput,
35745
35832
  Divider: BkDivider,
@@ -35785,4 +35872,4 @@ var preset = {
35785
35872
  install: createInstall(),
35786
35873
  version: "0.0.1"
35787
35874
  };
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 };
35875
+ 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 };