@deot/vc-components 1.0.12 → 1.0.13

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']
@@ -12122,7 +12122,7 @@ const props$m = {
12122
12122
  color: {
12123
12123
  type: [Object, String],
12124
12124
  default: () => ({
12125
- normal: "#5495f6",
12125
+ normal: "#2B72FD",
12126
12126
  success: "#52c41a",
12127
12127
  error: "#f5222d"
12128
12128
  })
@@ -13362,6 +13362,8 @@ const RecycleList = /* @__PURE__ */ defineComponent({
13362
13362
  });
13363
13363
  if (!originalData.length) {
13364
13364
  rebuildData.value = [];
13365
+ } else {
13366
+ rebuildData.value = originalData.slice();
13365
13367
  }
13366
13368
  offsetPageSize.value = 0;
13367
13369
  await refreshLayout(0, originalData.length);
@@ -14504,17 +14506,24 @@ class Store extends BaseWatcher {
14504
14506
  const dataInstanceChanged = this.states._data !== data;
14505
14507
  this.states._data = data;
14506
14508
  this.states.data = data;
14509
+ const caches = /* @__PURE__ */ new Map();
14510
+ this.states.list.forEach((item) => {
14511
+ item.rows.forEach((row) => {
14512
+ caches.set(row.data, row);
14513
+ });
14514
+ });
14507
14515
  this.states.list = data.reduce((pre, row, index) => {
14516
+ const cache = caches.get(row) || { heightMap: {} };
14508
14517
  pre.push({
14509
14518
  rows: [
14510
14519
  {
14511
14520
  index,
14512
14521
  data: row,
14513
- height: "",
14522
+ height: cache.height || "",
14514
14523
  heightMap: {
14515
- left: "",
14516
- main: "",
14517
- right: ""
14524
+ left: cache.heightMap.left || "",
14525
+ main: cache.heightMap.main || "",
14526
+ right: cache.heightMap.right || ""
14518
14527
  }
14519
14528
  }
14520
14529
  ],
@@ -14522,6 +14531,7 @@ class Store extends BaseWatcher {
14522
14531
  });
14523
14532
  return pre;
14524
14533
  }, []);
14534
+ caches.clear();
14525
14535
  this.current.update();
14526
14536
  this.expand.update();
14527
14537
  if (!this.states.reserveSelection) {
@@ -14655,12 +14665,12 @@ class Store extends BaseWatcher {
14655
14665
  */
14656
14666
  cleanSelection() {
14657
14667
  const { primaryKey } = this.table.props;
14658
- const { selection = [] } = this.states;
14668
+ const { selection = [], data } = this.states;
14659
14669
  let deleted;
14660
14670
  if (primaryKey) {
14661
14671
  deleted = [];
14662
14672
  const selectedMap = getValuesMap(selection, primaryKey);
14663
- const dataMap = getValuesMap(selection, primaryKey);
14673
+ const dataMap = getValuesMap(data, primaryKey);
14664
14674
  for (const key in selectedMap) {
14665
14675
  if (hasOwn(selectedMap, key) && !dataMap[key]) {
14666
14676
  deleted.push(selectedMap[key].row);
@@ -14835,8 +14845,10 @@ const COMPONENT_NAME$h = 'vc-table-normal-list';
14835
14845
  const NormalList = /* @__PURE__ */ defineComponent({
14836
14846
  name: COMPONENT_NAME$h,
14837
14847
  props: {
14838
- data: Array,
14839
- default: () => []
14848
+ data: {
14849
+ type: Array,
14850
+ default: () => []
14851
+ }
14840
14852
  },
14841
14853
  emits: ['row-resize'],
14842
14854
  setup(props, {
@@ -14878,7 +14890,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
14878
14890
  expose
14879
14891
  }) {
14880
14892
  const instance = getCurrentInstance();
14881
- const table = getInstance('table', 'tableId');
14893
+ const table = inject('vc-table');
14882
14894
  const states = useStates({
14883
14895
  data: 'data',
14884
14896
  list: 'list',
@@ -15002,7 +15014,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
15002
15014
  column,
15003
15015
  row
15004
15016
  };
15005
- table.exposed.hoverState.value = hoverState;
15017
+ table.hoverState.value = hoverState;
15006
15018
  table.emit('cell-mouse-enter', hoverState.row, hoverState.column, hoverState.cell, e);
15007
15019
  }
15008
15020
 
@@ -15035,7 +15047,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
15035
15047
  const handleCellMouseLeave = e => {
15036
15048
  const cell = getCell(e);
15037
15049
  if (!cell) return;
15038
- const oldHoverState = table.exposed.hoverState.value || {};
15050
+ const oldHoverState = table.hoverState.value || {};
15039
15051
  table.emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, e);
15040
15052
  };
15041
15053
  const handleMouseEnter = debounce(index => {
@@ -15073,6 +15085,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
15073
15085
  columns
15074
15086
  } = states;
15075
15087
  const key = getValueOfRow(row, rowIndex);
15088
+ const selected = props.store.isSelected(row);
15076
15089
  return createVNode("div", {
15077
15090
  "key": key,
15078
15091
  "class": [getRowClass(row, rowIndex), 'vc-table__tr'],
@@ -15093,10 +15106,12 @@ const TableBody = /* @__PURE__ */ defineComponent({
15093
15106
  };
15094
15107
  if (columnsHidden.value[columnIndex]) {
15095
15108
  return createVNode("div", {
15109
+ "key": column.id,
15096
15110
  "style": [sizeStyle]
15097
15111
  }, null);
15098
15112
  }
15099
15113
  return createVNode("div", {
15114
+ "key": column.id,
15100
15115
  "style": [getCellStyle(rowIndex, columnIndex, row, column), sizeStyle],
15101
15116
  "class": [getCellClass(rowIndex, columnIndex, row, column), 'vc-table__td'],
15102
15117
  "onMouseenter": e => handleCellMouseEnter(e, row),
@@ -15106,7 +15121,8 @@ const TableBody = /* @__PURE__ */ defineComponent({
15106
15121
  column,
15107
15122
  rowIndex,
15108
15123
  columnIndex,
15109
- store: props.store
15124
+ store: props.store,
15125
+ selected
15110
15126
  })]);
15111
15127
  })]);
15112
15128
  };
@@ -15140,7 +15156,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
15140
15156
  wrapper,
15141
15157
  getRootElement: () => instance.vnode.el
15142
15158
  });
15143
- const layout = table.exposed.layout;
15159
+ const layout = table.layout;
15144
15160
  return () => {
15145
15161
  return createVNode("div", {
15146
15162
  "class": "vc-table__body"
@@ -15150,7 +15166,7 @@ const TableBody = /* @__PURE__ */ defineComponent({
15150
15166
  "disabled": true,
15151
15167
  "class": "vc-table__tbody",
15152
15168
  "scrollerOptions": {
15153
- barTo: `.${table.exposed.tableId}`,
15169
+ barTo: `.${table.tableId}`,
15154
15170
  native: false,
15155
15171
  always: false,
15156
15172
  showBar: !props.fixed,
@@ -15202,7 +15218,7 @@ const TableHeader = /* @__PURE__ */ defineComponent({
15202
15218
  }
15203
15219
  },
15204
15220
  setup(props) {
15205
- const table = getInstance('table', 'tableId');
15221
+ const table = inject('vc-table');
15206
15222
  const instance = getCurrentInstance();
15207
15223
  const draggingColumn = ref(null);
15208
15224
  const dragging = ref(false);
@@ -15309,7 +15325,7 @@ const TableHeader = /* @__PURE__ */ defineComponent({
15309
15325
  /* istanbul ignore if */
15310
15326
  if (draggingColumn.value && props.border) {
15311
15327
  dragging.value = true;
15312
- table.exposed.resizeProxyVisible.value = true;
15328
+ table.resizeProxyVisible.value = true;
15313
15329
  const tableEl = table.vnode.el;
15314
15330
  const tableLeft = tableEl.getBoundingClientRect().left;
15315
15331
  const columnEl = instance.vnode.el.querySelector(`.vc-table__th.${column.id}`);
@@ -15322,7 +15338,7 @@ const TableHeader = /* @__PURE__ */ defineComponent({
15322
15338
  startColumnLeft: columnRect.left - tableLeft,
15323
15339
  tableLeft
15324
15340
  };
15325
- const resizeProxy = table.exposed.resizeProxy.value;
15341
+ const resizeProxy = table.resizeProxy.value;
15326
15342
  resizeProxy.style.left = dragState.value.startLeft + 'px';
15327
15343
  document.onselectstart = () => false;
15328
15344
  document.ondragstart = () => false;
@@ -15681,7 +15697,8 @@ const Table = /* @__PURE__ */ defineComponent({
15681
15697
  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
15698
  setup(props, {
15683
15699
  slots,
15684
- expose
15700
+ expose,
15701
+ emit
15685
15702
  }) {
15686
15703
  const instance = getCurrentInstance();
15687
15704
  const store = new Store({
@@ -16001,8 +16018,8 @@ const Table = /* @__PURE__ */ defineComponent({
16001
16018
  }, {
16002
16019
  immediate: true
16003
16020
  });
16004
- watch(() => props.data, v => {
16005
- store.setData(v);
16021
+ watch(() => [props.data, props.data.length], () => {
16022
+ store.setData(props.data);
16006
16023
  isReady.value && nextTick(refreshLayout);
16007
16024
  }, {
16008
16025
  immediate: true
@@ -16040,7 +16057,7 @@ const Table = /* @__PURE__ */ defineComponent({
16040
16057
  isUnMount = true;
16041
16058
  unbindEvents();
16042
16059
  });
16043
- expose({
16060
+ const exposed = {
16044
16061
  bodyXWrapper,
16045
16062
  bodyYWrapper,
16046
16063
  tableId,
@@ -16062,8 +16079,12 @@ const Table = /* @__PURE__ */ defineComponent({
16062
16079
  isReady,
16063
16080
  hoverState,
16064
16081
  renderExpanded,
16065
- hiddenColumns
16066
- });
16082
+ hiddenColumns,
16083
+ props,
16084
+ emit
16085
+ };
16086
+ expose(exposed);
16087
+ provide('vc-table', exposed);
16067
16088
  return () => {
16068
16089
  return createVNode("div", {
16069
16090
  "class": [classes.value, tableId, 'vc-table'],
@@ -16250,10 +16271,11 @@ const cellForced = {
16250
16271
  column,
16251
16272
  store,
16252
16273
  rowIndex,
16253
- level
16274
+ level,
16275
+ selected
16254
16276
  }) {
16255
16277
  return withDirectives(createVNode(Checkbox, {
16256
- "modelValue": store.isSelected(row),
16278
+ "modelValue": selected,
16257
16279
  "disabled": column.selectable ? !column.selectable.call(null, row, rowIndex) : false,
16258
16280
  "onChange": () => store.rowSelectedChanged(row),
16259
16281
  "onClick": e => e.stopPropagation()
@@ -16426,15 +16448,14 @@ const TableColumn = /* @__PURE__ */ defineComponent({
16426
16448
  tooltip: [String, Function]
16427
16449
  },
16428
16450
  setup(props, {
16429
- slots,
16430
- expose
16451
+ slots
16431
16452
  }) {
16432
16453
  const instance = getCurrentInstance();
16433
- const table = getInstance('table', 'tableId');
16434
- const parent = getInstance('table-column', 'columnId') || table;
16454
+ const table = inject('vc-table');
16455
+ const parent = inject('vc-table-column', table);
16435
16456
  const isSubColumn = table !== parent; // 用于多久表头
16436
16457
 
16437
- const columnId = ref((parent.exposed.tableId || parent.exposed.columnId) + getUid('column'));
16458
+ const columnId = ref((parent.tableId || parent.columnId) + getUid('column'));
16438
16459
  const realWidth = computed(() => {
16439
16460
  return parseWidth(props.width);
16440
16461
  });
@@ -16533,7 +16554,7 @@ const TableColumn = /* @__PURE__ */ defineComponent({
16533
16554
  column.renderCell = data => createVNode("div", {
16534
16555
  "class": "vc-table__cell"
16535
16556
  }, [originRenderCell(data)]);
16536
- table.exposed.renderExpanded.value = data => {
16557
+ table.renderExpanded.value = data => {
16537
16558
  return slots.default ? slots.default(data) : slots.default;
16538
16559
  };
16539
16560
  } else {
@@ -16552,7 +16573,7 @@ const TableColumn = /* @__PURE__ */ defineComponent({
16552
16573
  style: {}
16553
16574
  };
16554
16575
  // 存在树形数组,且当前行无箭头图标且处于当前展开列,表格对齐
16555
- if (!isEmpty$1(table.exposed.store.states.treeData) && !prefix && data.isExpandColumn) {
16576
+ if (!isEmpty$1(table.store.states.treeData) && !prefix && data.isExpandColumn) {
16556
16577
  prefix = createVNode("span", {
16557
16578
  "class": "vc-table-un-expand__indent"
16558
16579
  }, null);
@@ -16595,15 +16616,15 @@ const TableColumn = /* @__PURE__ */ defineComponent({
16595
16616
 
16596
16617
  // 影响布局
16597
16618
  watch(() => props.fixed, () => {
16598
- table.exposed.store.scheduleLayout(true);
16619
+ table.store.scheduleLayout(true);
16599
16620
  });
16600
16621
  watch(() => realWidth.value, v => {
16601
16622
  columnConfig['width'] = v;
16602
16623
  columnConfig['realWidth'] = v;
16603
- table.exposed.store.scheduleLayout(false);
16624
+ table.store.scheduleLayout(false);
16604
16625
  });
16605
16626
  watch(() => realMinWidth.value, () => {
16606
- table.exposed.store.scheduleLayout(false);
16627
+ table.store.scheduleLayout(false);
16607
16628
  });
16608
16629
  };
16609
16630
  onBeforeMount(() => {
@@ -16611,17 +16632,17 @@ const TableColumn = /* @__PURE__ */ defineComponent({
16611
16632
  registerWatchers();
16612
16633
  });
16613
16634
  onMounted(() => {
16614
- const children = isSubColumn ? parent.vnode.el.children : parent.exposed.hiddenColumns.value.children;
16635
+ const children = isSubColumn ? parent.vnode.el.children : parent.hiddenColumns.value.children;
16615
16636
 
16616
16637
  // DOM上
16617
16638
  const columnIndex = [...children].indexOf(instance.vnode.el);
16618
- table.exposed.store.insertColumn(columnConfig, columnIndex, isSubColumn && parent.exposed.columnConfig);
16639
+ table.store.insertColumn(columnConfig, columnIndex, isSubColumn && parent.columnConfig);
16619
16640
  });
16620
16641
  onUnmounted(() => {
16621
16642
  if (!instance.parent) return;
16622
- table.exposed.store.removeColumn(columnConfig, isSubColumn && parent.exposed.columnConfig);
16643
+ table.store.removeColumn(columnConfig, isSubColumn && parent.columnConfig);
16623
16644
  });
16624
- expose({
16645
+ provide('vc-table-column', {
16625
16646
  columnId,
16626
16647
  columnConfig
16627
16648
  });