@deot/vc-components 1.0.12 → 1.0.14

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.js CHANGED
@@ -772,7 +772,7 @@ const COMPONENT_NAME$1T = 'vc-alert';
772
772
 
773
773
  // [color, borderColor, backgroundColor], -> CSS
774
774
  const THEME_MAP = {
775
- info: ['#5495f6', '#91d5ff', '#e6f7ff'],
775
+ info: ['#2B72FD', '#91d5ff', '#e6f7ff'],
776
776
  success: ['#52c41a', '#b7eb8f', '#f6ffed'],
777
777
  error: ['#ed4014', '#ffb08f', '#fbe9e9'],
778
778
  warning: ['#ffbf00', '#ffe58f', '#fffbe6']
@@ -10263,7 +10263,7 @@ const props$z = {
10263
10263
  validator: (v) => /(small|medium|large)/.test(v),
10264
10264
  default: "small"
10265
10265
  },
10266
- portalClass: [Object, String],
10266
+ contentClass: [Object, String],
10267
10267
  width: {
10268
10268
  type: Number
10269
10269
  },
@@ -10312,6 +10312,10 @@ const props$z = {
10312
10312
  type: Boolean,
10313
10313
  default: true
10314
10314
  },
10315
+ border: {
10316
+ type: Boolean,
10317
+ default: false
10318
+ },
10315
10319
  /**
10316
10320
  * 兼容portal设计, 实现Promise方式
10317
10321
  */
@@ -10609,7 +10613,8 @@ const ModalView = /* @__PURE__ */ defineComponent({
10609
10613
  "class": [{
10610
10614
  'is-drag': props.draggable,
10611
10615
  'is-large': props.size === 'large' || props.size === 'medium',
10612
- 'is-no-footer': !props.footer || !props.cancelText && !props.okText
10616
+ 'has-footer': props.footer && (props.cancelText || props.okText),
10617
+ 'has-border': props.border
10613
10618
  }, 'vc-modal__container'],
10614
10619
  "style": [basicStyle.value, draggableStyle.value]
10615
10620
  }, [createVNode("div", {
@@ -10641,7 +10646,7 @@ const ModalView = /* @__PURE__ */ defineComponent({
10641
10646
  "height": isTransitionEnd.value ? row.height : void 0,
10642
10647
  "contentClass": [{
10643
10648
  'is-confirm': props.mode
10644
- }, props.portalClass, 'vc-modal__content']
10649
+ }, props.contentClass, 'vc-modal__content']
10645
10650
  }, {
10646
10651
  default: () => [typeof props.content === 'string' ? createVNode("div", {
10647
10652
  "innerHTML": props.content
@@ -12122,7 +12127,7 @@ const props$m = {
12122
12127
  color: {
12123
12128
  type: [Object, String],
12124
12129
  default: () => ({
12125
- normal: "#5495f6",
12130
+ normal: "#2B72FD",
12126
12131
  success: "#52c41a",
12127
12132
  error: "#f5222d"
12128
12133
  })
@@ -13362,6 +13367,8 @@ const RecycleList = /* @__PURE__ */ defineComponent({
13362
13367
  });
13363
13368
  if (!originalData.length) {
13364
13369
  rebuildData.value = [];
13370
+ } else {
13371
+ rebuildData.value = originalData.slice();
13365
13372
  }
13366
13373
  offsetPageSize.value = 0;
13367
13374
  await refreshLayout(0, originalData.length);
@@ -14504,17 +14511,24 @@ class Store extends BaseWatcher {
14504
14511
  const dataInstanceChanged = this.states._data !== data;
14505
14512
  this.states._data = data;
14506
14513
  this.states.data = data;
14514
+ const caches = /* @__PURE__ */ new Map();
14515
+ this.states.list.forEach((item) => {
14516
+ item.rows.forEach((row) => {
14517
+ caches.set(row.data, row);
14518
+ });
14519
+ });
14507
14520
  this.states.list = data.reduce((pre, row, index) => {
14521
+ const cache = caches.get(row) || { heightMap: {} };
14508
14522
  pre.push({
14509
14523
  rows: [
14510
14524
  {
14511
14525
  index,
14512
14526
  data: row,
14513
- height: "",
14527
+ height: cache.height || "",
14514
14528
  heightMap: {
14515
- left: "",
14516
- main: "",
14517
- right: ""
14529
+ left: cache.heightMap.left || "",
14530
+ main: cache.heightMap.main || "",
14531
+ right: cache.heightMap.right || ""
14518
14532
  }
14519
14533
  }
14520
14534
  ],
@@ -14522,6 +14536,7 @@ class Store extends BaseWatcher {
14522
14536
  });
14523
14537
  return pre;
14524
14538
  }, []);
14539
+ caches.clear();
14525
14540
  this.current.update();
14526
14541
  this.expand.update();
14527
14542
  if (!this.states.reserveSelection) {
@@ -14655,12 +14670,12 @@ class Store extends BaseWatcher {
14655
14670
  */
14656
14671
  cleanSelection() {
14657
14672
  const { primaryKey } = this.table.props;
14658
- const { selection = [] } = this.states;
14673
+ const { selection = [], data } = this.states;
14659
14674
  let deleted;
14660
14675
  if (primaryKey) {
14661
14676
  deleted = [];
14662
14677
  const selectedMap = getValuesMap(selection, primaryKey);
14663
- const dataMap = getValuesMap(selection, primaryKey);
14678
+ const dataMap = getValuesMap(data, primaryKey);
14664
14679
  for (const key in selectedMap) {
14665
14680
  if (hasOwn(selectedMap, key) && !dataMap[key]) {
14666
14681
  deleted.push(selectedMap[key].row);
@@ -14835,8 +14850,10 @@ const COMPONENT_NAME$h = 'vc-table-normal-list';
14835
14850
  const NormalList = /* @__PURE__ */ defineComponent({
14836
14851
  name: COMPONENT_NAME$h,
14837
14852
  props: {
14838
- data: Array,
14839
- default: () => []
14853
+ data: {
14854
+ type: Array,
14855
+ default: () => []
14856
+ }
14840
14857
  },
14841
14858
  emits: ['row-resize'],
14842
14859
  setup(props, {
@@ -14878,7 +14895,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
14878
14895
  expose
14879
14896
  }) {
14880
14897
  const instance = getCurrentInstance();
14881
- const table = getInstance('table', 'tableId');
14898
+ const table = inject('vc-table');
14882
14899
  const states = useStates({
14883
14900
  data: 'data',
14884
14901
  list: 'list',
@@ -15002,7 +15019,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
15002
15019
  column,
15003
15020
  row
15004
15021
  };
15005
- table.exposed.hoverState.value = hoverState;
15022
+ table.hoverState.value = hoverState;
15006
15023
  table.emit('cell-mouse-enter', hoverState.row, hoverState.column, hoverState.cell, e);
15007
15024
  }
15008
15025
 
@@ -15035,7 +15052,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
15035
15052
  const handleCellMouseLeave = e => {
15036
15053
  const cell = getCell(e);
15037
15054
  if (!cell) return;
15038
- const oldHoverState = table.exposed.hoverState.value || {};
15055
+ const oldHoverState = table.hoverState.value || {};
15039
15056
  table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, e);
15040
15057
  };
15041
15058
  const handleMouseEnter = debounce(index => {
@@ -15073,6 +15090,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
15073
15090
  columns
15074
15091
  } = states;
15075
15092
  const key = getValueOfRow(row, rowIndex);
15093
+ const selected = props.store.isSelected(row);
15076
15094
  return createVNode("div", {
15077
15095
  "key": key,
15078
15096
  "class": [getRowClass(row, rowIndex), 'vc-table__tr'],
@@ -15093,10 +15111,12 @@ const TableBody = /* @__PURE__ */ defineComponent({
15093
15111
  };
15094
15112
  if (columnsHidden.value[columnIndex]) {
15095
15113
  return createVNode("div", {
15114
+ "key": column.id,
15096
15115
  "style": [sizeStyle]
15097
15116
  }, null);
15098
15117
  }
15099
15118
  return createVNode("div", {
15119
+ "key": column.id,
15100
15120
  "style": [getCellStyle(rowIndex, columnIndex, row, column), sizeStyle],
15101
15121
  "class": [getCellClass(rowIndex, columnIndex, row, column), 'vc-table__td'],
15102
15122
  "onMouseenter": e => handleCellMouseEnter(e, row),
@@ -15106,7 +15126,8 @@ const TableBody = /* @__PURE__ */ defineComponent({
15106
15126
  column,
15107
15127
  rowIndex,
15108
15128
  columnIndex,
15109
- store: props.store
15129
+ store: props.store,
15130
+ selected
15110
15131
  })]);
15111
15132
  })]);
15112
15133
  };
@@ -15140,7 +15161,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
15140
15161
  wrapper,
15141
15162
  getRootElement: () => instance.vnode.el
15142
15163
  });
15143
- const layout = table.exposed.layout;
15164
+ const layout = table.layout;
15144
15165
  return () => {
15145
15166
  return createVNode("div", {
15146
15167
  "class": "vc-table__body"
@@ -15150,7 +15171,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
15150
15171
  "disabled": true,
15151
15172
  "class": "vc-table__tbody",
15152
15173
  "scrollerOptions": {
15153
- barTo: `.${table.exposed.tableId}`,
15174
+ barTo: `.${table.tableId}`,
15154
15175
  native: false,
15155
15176
  always: false,
15156
15177
  showBar: !props.fixed,
@@ -15202,7 +15223,7 @@ const TableHeader = /* @__PURE__ */ defineComponent({
15202
15223
  }
15203
15224
  },
15204
15225
  setup(props) {
15205
- const table = getInstance('table', 'tableId');
15226
+ const table = inject('vc-table');
15206
15227
  const instance = getCurrentInstance();
15207
15228
  const draggingColumn = ref(null);
15208
15229
  const dragging = ref(false);
@@ -15309,7 +15330,7 @@ const TableHeader = /* @__PURE__ */ defineComponent({
15309
15330
  /* istanbul ignore if */
15310
15331
  if (draggingColumn.value && props.border) {
15311
15332
  dragging.value = true;
15312
- table.exposed.resizeProxyVisible.value = true;
15333
+ table.resizeProxyVisible.value = true;
15313
15334
  const tableEl = table.vnode.el;
15314
15335
  const tableLeft = tableEl.getBoundingClientRect().left;
15315
15336
  const columnEl = instance.vnode.el.querySelector(`.vc-table__th.${column.id}`);
@@ -15322,7 +15343,7 @@ const TableHeader = /* @__PURE__ */ defineComponent({
15322
15343
  startColumnLeft: columnRect.left - tableLeft,
15323
15344
  tableLeft
15324
15345
  };
15325
- const resizeProxy = table.exposed.resizeProxy.value;
15346
+ const resizeProxy = table.resizeProxy.value;
15326
15347
  resizeProxy.style.left = dragState.value.startLeft + 'px';
15327
15348
  document.onselectstart = () => false;
15328
15349
  document.ondragstart = () => false;
@@ -15681,7 +15702,8 @@ const Table = /* @__PURE__ */ defineComponent({
15681
15702
  emits: ['select', 'select-all', 'selection-change', 'cell-mouse-enter', 'cell-mouse-leave', 'cell-click', 'cell-dblclick', 'row-click', 'row-contextmenu', 'row-dblclick', 'header-click', 'header-contextmenu', 'current-change', 'header-dragend ', 'expand-change', 'sort-change'],
15682
15703
  setup(props, {
15683
15704
  slots,
15684
- expose
15705
+ expose,
15706
+ emit
15685
15707
  }) {
15686
15708
  const instance = getCurrentInstance();
15687
15709
  const store = new Store({
@@ -15797,7 +15819,8 @@ const Table = /* @__PURE__ */ defineComponent({
15797
15819
  };
15798
15820
  }
15799
15821
  return {
15800
- height: layout.states.viewportHeight ? layout.states.viewportHeight + 'px' : ''
15822
+ height: layout.states.viewportHeight ? layout.states.viewportHeight + 'px' : '',
15823
+ bottom: 0
15801
15824
  };
15802
15825
  }
15803
15826
  });
@@ -16001,8 +16024,8 @@ const Table = /* @__PURE__ */ defineComponent({
16001
16024
  }, {
16002
16025
  immediate: true
16003
16026
  });
16004
- watch(() => props.data, v => {
16005
- store.setData(v);
16027
+ watch(() => [props.data, props.data.length], () => {
16028
+ store.setData(props.data);
16006
16029
  isReady.value && nextTick(refreshLayout);
16007
16030
  }, {
16008
16031
  immediate: true
@@ -16040,7 +16063,7 @@ const Table = /* @__PURE__ */ defineComponent({
16040
16063
  isUnMount = true;
16041
16064
  unbindEvents();
16042
16065
  });
16043
- expose({
16066
+ const exposed = {
16044
16067
  bodyXWrapper,
16045
16068
  bodyYWrapper,
16046
16069
  tableId,
@@ -16062,8 +16085,12 @@ const Table = /* @__PURE__ */ defineComponent({
16062
16085
  isReady,
16063
16086
  hoverState,
16064
16087
  renderExpanded,
16065
- hiddenColumns
16066
- });
16088
+ hiddenColumns,
16089
+ props,
16090
+ emit
16091
+ };
16092
+ expose(exposed);
16093
+ provide('vc-table', exposed);
16067
16094
  return () => {
16068
16095
  return createVNode("div", {
16069
16096
  "class": [classes.value, tableId, 'vc-table'],
@@ -16099,7 +16126,9 @@ const Table = /* @__PURE__ */ defineComponent({
16099
16126
  }, null), props.data.length === 0 && createVNode("div", {
16100
16127
  "ref": emptyBlock,
16101
16128
  "style": bodyWidthStyle.value,
16102
- "class": "vc-table__empty-block"
16129
+ "class": [{
16130
+ 'is-absolute': !!props.height
16131
+ }, 'vc-table__empty-wrapper']
16103
16132
  }, [createVNode("span", {
16104
16133
  "class": "vc-table__empty-text"
16105
16134
  }, [slots.empty ? slots.empty() : props.emptyText || '暂无数据'])]), slots.append && createVNode("div", {
@@ -16250,10 +16279,11 @@ const cellForced = {
16250
16279
  column,
16251
16280
  store,
16252
16281
  rowIndex,
16253
- level
16282
+ level,
16283
+ selected
16254
16284
  }) {
16255
16285
  return withDirectives(createVNode(Checkbox, {
16256
- "modelValue": store.isSelected(row),
16286
+ "modelValue": selected,
16257
16287
  "disabled": column.selectable ? !column.selectable.call(null, row, rowIndex) : false,
16258
16288
  "onChange": () => store.rowSelectedChanged(row),
16259
16289
  "onClick": e => e.stopPropagation()
@@ -16426,15 +16456,14 @@ const TableColumn = /* @__PURE__ */ defineComponent({
16426
16456
  tooltip: [String, Function]
16427
16457
  },
16428
16458
  setup(props, {
16429
- slots,
16430
- expose
16459
+ slots
16431
16460
  }) {
16432
16461
  const instance = getCurrentInstance();
16433
- const table = getInstance('table', 'tableId');
16434
- const parent = getInstance('table-column', 'columnId') || table;
16462
+ const table = inject('vc-table');
16463
+ const parent = inject('vc-table-column', table);
16435
16464
  const isSubColumn = table !== parent; // 用于多久表头
16436
16465
 
16437
- const columnId = ref((parent.exposed.tableId || parent.exposed.columnId) + getUid('column'));
16466
+ const columnId = ref((parent.tableId || parent.columnId) + getUid('column'));
16438
16467
  const realWidth = computed(() => {
16439
16468
  return parseWidth(props.width);
16440
16469
  });
@@ -16533,7 +16562,7 @@ const TableColumn = /* @__PURE__ */ defineComponent({
16533
16562
  column.renderCell = data => createVNode("div", {
16534
16563
  "class": "vc-table__cell"
16535
16564
  }, [originRenderCell(data)]);
16536
- table.exposed.renderExpanded.value = data => {
16565
+ table.renderExpanded.value = data => {
16537
16566
  return slots.default ? slots.default(data) : slots.default;
16538
16567
  };
16539
16568
  } else {
@@ -16552,7 +16581,7 @@ const TableColumn = /* @__PURE__ */ defineComponent({
16552
16581
  style: {}
16553
16582
  };
16554
16583
  // 存在树形数组,且当前行无箭头图标且处于当前展开列,表格对齐
16555
- if (!isEmpty$1(table.exposed.store.states.treeData) && !prefix && data.isExpandColumn) {
16584
+ if (!isEmpty$1(table.store.states.treeData) && !prefix && data.isExpandColumn) {
16556
16585
  prefix = createVNode("span", {
16557
16586
  "class": "vc-table-un-expand__indent"
16558
16587
  }, null);
@@ -16595,15 +16624,15 @@ const TableColumn = /* @__PURE__ */ defineComponent({
16595
16624
 
16596
16625
  // 影响布局
16597
16626
  watch(() => props.fixed, () => {
16598
- table.exposed.store.scheduleLayout(true);
16627
+ table.store.scheduleLayout(true);
16599
16628
  });
16600
16629
  watch(() => realWidth.value, v => {
16601
16630
  columnConfig['width'] = v;
16602
16631
  columnConfig['realWidth'] = v;
16603
- table.exposed.store.scheduleLayout(false);
16632
+ table.store.scheduleLayout(false);
16604
16633
  });
16605
16634
  watch(() => realMinWidth.value, () => {
16606
- table.exposed.store.scheduleLayout(false);
16635
+ table.store.scheduleLayout(false);
16607
16636
  });
16608
16637
  };
16609
16638
  onBeforeMount(() => {
@@ -16611,17 +16640,17 @@ const TableColumn = /* @__PURE__ */ defineComponent({
16611
16640
  registerWatchers();
16612
16641
  });
16613
16642
  onMounted(() => {
16614
- const children = isSubColumn ? parent.vnode.el.children : parent.exposed.hiddenColumns.value.children;
16643
+ const children = isSubColumn ? parent.vnode.el.children : parent.hiddenColumns.value.children;
16615
16644
 
16616
16645
  // DOM上
16617
16646
  const columnIndex = [...children].indexOf(instance.vnode.el);
16618
- table.exposed.store.insertColumn(columnConfig, columnIndex, isSubColumn && parent.exposed.columnConfig);
16647
+ table.store.insertColumn(columnConfig, columnIndex, isSubColumn && parent.columnConfig);
16619
16648
  });
16620
16649
  onUnmounted(() => {
16621
16650
  if (!instance.parent) return;
16622
- table.exposed.store.removeColumn(columnConfig, isSubColumn && parent.exposed.columnConfig);
16651
+ table.store.removeColumn(columnConfig, isSubColumn && parent.columnConfig);
16623
16652
  });
16624
- expose({
16653
+ provide('vc-table-column', {
16625
16654
  columnId,
16626
16655
  columnConfig
16627
16656
  });
@@ -16862,7 +16891,7 @@ const Tabs = /* @__PURE__ */ defineComponent({
16862
16891
  if (!Array.from(items).length) return;
16863
16892
  let offset = 0;
16864
16893
  if (index > 0) {
16865
- const gutter = 16; // margin-right -> 16px
16894
+ const gutter = 12; // margin-right -> 12px
16866
16895
  for (let i = 0; i < index; i++) {
16867
16896
  offset += parseFloat(items[i].offsetWidth) + gutter;
16868
16897
  }
@@ -16934,7 +16963,7 @@ const Tabs = /* @__PURE__ */ defineComponent({
16934
16963
  }, [slots.extra?.()]), createVNode("div", {
16935
16964
  "ref": wrapper,
16936
16965
  "style": {
16937
- padding: tabs.scrollable.value && '0 24px'
16966
+ padding: tabs.scrollable.value ? '0 24px' : 0
16938
16967
  },
16939
16968
  "class": "vc-tabs__bar"
16940
16969
  }, [tabs.scrollable.value && createVNode(Icon, {