3h1-ui 3.0.0-next.43 → 3.0.0-next.45

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.
Files changed (3) hide show
  1. package/es/index.js +53 -34
  2. package/lib/index.js +53 -34
  3. package/package.json +4 -5
package/es/index.js CHANGED
@@ -37073,9 +37073,9 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37073
37073
  const table2 = useTableContext();
37074
37074
  const defaultRowSelection = omit$1(table2.getRowSelection(), "selectedRowKeys");
37075
37075
  let inited = false;
37076
+ let inset = false;
37076
37077
  const cachePlainOptions = ref([]);
37077
37078
  const plainOptions = ref([]);
37078
- const plainSortOptions = ref([]);
37079
37079
  const columnListRef = ref(null);
37080
37080
  const state = reactive({
37081
37081
  checkAll: true,
@@ -37091,7 +37091,7 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37091
37091
  return unref(table2 == null ? void 0 : table2.getBindValues) || {};
37092
37092
  });
37093
37093
  watch(() => table2.getColumns(), () => {
37094
- if (!state.isInit)
37094
+ if (!state.isInit || inset)
37095
37095
  return;
37096
37096
  reInit();
37097
37097
  }, {
@@ -37117,9 +37117,9 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37117
37117
  ignoreAction: true
37118
37118
  }).forEach((item) => {
37119
37119
  ret.push({
37120
- label: item.title || item.customTitle,
37121
- value: item.dataIndex || item.title,
37122
- ...item
37120
+ ...item,
37121
+ title: item.title || item.customTitle,
37122
+ dataIndex: item.dataIndex || item.title
37123
37123
  });
37124
37124
  });
37125
37125
  return ret;
@@ -37137,7 +37137,6 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37137
37137
  }).filter(Boolean);
37138
37138
  if (!plainOptions.value.length) {
37139
37139
  plainOptions.value = columns;
37140
- plainSortOptions.value = columns;
37141
37140
  cachePlainOptions.value = columns;
37142
37141
  state.defaultCheckList = checkList;
37143
37142
  } else {
@@ -37154,8 +37153,6 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37154
37153
  }
37155
37154
  const reInit = () => {
37156
37155
  const columns = getColumns();
37157
- plainOptions.value = columns;
37158
- cachePlainOptions.value = columns;
37159
37156
  unref(plainOptions).forEach((item) => {
37160
37157
  const findItem = columns.find((col) => col.dataIndex === item.dataIndex);
37161
37158
  if (findItem) {
@@ -37163,17 +37160,16 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37163
37160
  item.width = findItem.width;
37164
37161
  }
37165
37162
  });
37166
- const data = getResult(columns);
37167
- emit("columns-change", data);
37163
+ handleEmit(columns, false);
37168
37164
  };
37169
37165
  function onCheckAllChange(e) {
37170
- const checkList = plainOptions.value.map((item) => item.value);
37166
+ const checkList = plainOptions.value.map((item) => item.dataIndex);
37171
37167
  if (e.target.checked) {
37172
37168
  state.checkedList = checkList;
37173
- setColumns(checkList);
37169
+ handleEmit(checkList);
37174
37170
  } else {
37175
37171
  state.checkedList = [];
37176
- setColumns([]);
37172
+ handleEmit([]);
37177
37173
  }
37178
37174
  }
37179
37175
  const indeterminate = computed(() => {
@@ -37182,13 +37178,13 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37182
37178
  return checkedLen > 0 && checkedLen < len;
37183
37179
  });
37184
37180
  function onChange(checkedList) {
37185
- const len = plainSortOptions.value.length;
37181
+ const len = plainOptions.value.length;
37186
37182
  state.checkAll = checkedList.length === len;
37187
- const sortList = unref(plainSortOptions).map((item) => item.value);
37183
+ const sortList = unref(plainOptions).map((item) => item.dataIndex);
37188
37184
  checkedList.sort((prev2, next2) => {
37189
37185
  return sortList.indexOf(prev2) - sortList.indexOf(next2);
37190
37186
  });
37191
- setColumns(checkedList);
37187
+ handleEmit(checkedList);
37192
37188
  }
37193
37189
  let sortable;
37194
37190
  let sortableOrder = [];
@@ -37196,8 +37192,7 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37196
37192
  state.checkedList = [...state.defaultCheckList];
37197
37193
  state.checkAll = true;
37198
37194
  plainOptions.value = unref(cachePlainOptions);
37199
- plainSortOptions.value = unref(cachePlainOptions);
37200
- setColumns(table2.getCacheColumns());
37195
+ handleEmit(table2.getCacheColumns());
37201
37196
  sortable.sort(sortableOrder);
37202
37197
  }
37203
37198
  function handleVisibleChange() {
@@ -37223,7 +37218,7 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37223
37218
  if (isNullAndUnDef(oldIndex) || isNullAndUnDef(newIndex) || oldIndex === newIndex) {
37224
37219
  return;
37225
37220
  }
37226
- const columns = cloneDeep(plainSortOptions.value);
37221
+ const columns = cloneDeep(plainOptions.value);
37227
37222
  if (oldIndex > newIndex) {
37228
37223
  columns.splice(newIndex, 0, columns[oldIndex]);
37229
37224
  columns.splice(oldIndex + 1, 1);
@@ -37231,8 +37226,8 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37231
37226
  columns.splice(newIndex + 1, 0, columns[oldIndex]);
37232
37227
  columns.splice(oldIndex, 1);
37233
37228
  }
37234
- plainSortOptions.value = columns;
37235
- setColumns(columns.map((col) => col.value).filter((value) => state.checkedList.includes(value)));
37229
+ const tempCol = columns.map((col) => col.dataIndex).filter((value) => state.checkedList.includes(value));
37230
+ handleEmit(tempCol);
37236
37231
  }
37237
37232
  });
37238
37233
  sortableOrder = sortable.toArray();
@@ -37266,27 +37261,51 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37266
37261
  (_a2 = table2.setCacheColumnsByField) == null ? void 0 : _a2.call(table2, item.dataIndex, {
37267
37262
  fixed: isFixed
37268
37263
  });
37269
- setColumns(columns);
37264
+ handleEmit(columns);
37270
37265
  }
37271
37266
  function getResult(columns) {
37272
- return unref(plainOptions).map((col) => {
37273
- const defaultHidden = columns.findIndex((c) => c === col.value || typeof c !== "string" && c.dataIndex === col.value && (isBoolean(c.defaultHidden) ? c.defaultHidden : false)) !== -1;
37267
+ const tempOptions = unref(plainOptions).map((col) => {
37268
+ let defaultHidden = false;
37269
+ if (columns.every((val) => typeof val === "string")) {
37270
+ defaultHidden = columns.findIndex((val) => val === col.dataIndex) === -1;
37271
+ } else {
37272
+ const find = columns.find((val) => val.dataIndex === col.dataIndex);
37273
+ defaultHidden = find ? isBoolean(find.defaultHidden) ? find.defaultHidden : false : true;
37274
+ }
37274
37275
  return {
37275
- dataIndex: col.value,
37276
+ title: col.title,
37277
+ dataIndex: col.dataIndex,
37276
37278
  fixed: col.fixed,
37277
37279
  defaultHidden,
37278
37280
  width: col.width
37279
37281
  };
37280
37282
  });
37281
- }
37282
- function setColumns(columns) {
37283
- table2.setColumns(columns);
37284
- const data = getResult(columns);
37285
- emit("columns-change", data);
37283
+ if (!columns.every((val) => typeof val === "string")) {
37284
+ const sortList = columns.map((item) => item.dataIndex);
37285
+ tempOptions.sort((prev2, next2) => {
37286
+ return sortList.indexOf(prev2.dataIndex) - sortList.indexOf(next2.dataIndex);
37287
+ });
37288
+ return tempOptions;
37289
+ }
37290
+ tempOptions.sort((prev2, next2) => {
37291
+ return columns.indexOf(prev2.dataIndex) - columns.indexOf(next2.dataIndex);
37292
+ });
37293
+ return tempOptions;
37286
37294
  }
37287
37295
  function getPopupContainer2() {
37288
37296
  return isFunction$4(attrs.getPopupContainer) ? attrs.getPopupContainer() : getPopupContainer$1();
37289
37297
  }
37298
+ const handleEmit = useDebounceFn$1((columns, set2 = true) => {
37299
+ const data = getResult(columns);
37300
+ emit("columns-change", data);
37301
+ if (set2) {
37302
+ inset = true;
37303
+ table2.setColumns(columns);
37304
+ setTimeout(() => {
37305
+ inset = false;
37306
+ });
37307
+ }
37308
+ }, 100);
37290
37309
  return () => {
37291
37310
  return createVNode(Tooltip, {
37292
37311
  "placement": "top"
@@ -37342,9 +37361,9 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37342
37361
  }, [createVNode(DragOutlined$1, {
37343
37362
  "class": "table-column-drag-icon"
37344
37363
  }, null), createVNode(Checkbox, {
37345
- "value": item.value
37364
+ "value": item.dataIndex
37346
37365
  }, {
37347
- default: () => [item.label]
37366
+ default: () => [item.title]
37348
37367
  }), createVNode(Tooltip, {
37349
37368
  "placement": "bottomLeft",
37350
37369
  "mouseLeaveDelay": 0.4,
@@ -37354,7 +37373,7 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37354
37373
  "rotate": 90,
37355
37374
  "class": [`${prefixCls2}__fixed-left`, {
37356
37375
  active: item.fixed === "left",
37357
- disabled: !state.checkedList.includes(item.value)
37376
+ disabled: !state.checkedList.includes(item.dataIndex)
37358
37377
  }],
37359
37378
  "onClick": () => handleColumnFixed(item, "left")
37360
37379
  }, null)],
@@ -37370,7 +37389,7 @@ const ShyTableColumn = /* @__PURE__ */ defineComponent({
37370
37389
  "rotate": 90,
37371
37390
  "class": [`${prefixCls2}__fixed-right`, {
37372
37391
  active: item.fixed === "right",
37373
- disabled: !state.checkedList.includes(item.value)
37392
+ disabled: !state.checkedList.includes(item.dataIndex)
37374
37393
  }],
37375
37394
  "onClick": () => handleColumnFixed(item, "right")
37376
37395
  }, null)],
package/lib/index.js CHANGED
@@ -37097,9 +37097,9 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37097
37097
  const table2 = useTableContext();
37098
37098
  const defaultRowSelection = omit$1(table2.getRowSelection(), "selectedRowKeys");
37099
37099
  let inited = false;
37100
+ let inset = false;
37100
37101
  const cachePlainOptions = vue.ref([]);
37101
37102
  const plainOptions = vue.ref([]);
37102
- const plainSortOptions = vue.ref([]);
37103
37103
  const columnListRef = vue.ref(null);
37104
37104
  const state = vue.reactive({
37105
37105
  checkAll: true,
@@ -37115,7 +37115,7 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37115
37115
  return vue.unref(table2 == null ? void 0 : table2.getBindValues) || {};
37116
37116
  });
37117
37117
  vue.watch(() => table2.getColumns(), () => {
37118
- if (!state.isInit)
37118
+ if (!state.isInit || inset)
37119
37119
  return;
37120
37120
  reInit();
37121
37121
  }, {
@@ -37141,9 +37141,9 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37141
37141
  ignoreAction: true
37142
37142
  }).forEach((item) => {
37143
37143
  ret.push({
37144
- label: item.title || item.customTitle,
37145
- value: item.dataIndex || item.title,
37146
- ...item
37144
+ ...item,
37145
+ title: item.title || item.customTitle,
37146
+ dataIndex: item.dataIndex || item.title
37147
37147
  });
37148
37148
  });
37149
37149
  return ret;
@@ -37161,7 +37161,6 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37161
37161
  }).filter(Boolean);
37162
37162
  if (!plainOptions.value.length) {
37163
37163
  plainOptions.value = columns;
37164
- plainSortOptions.value = columns;
37165
37164
  cachePlainOptions.value = columns;
37166
37165
  state.defaultCheckList = checkList;
37167
37166
  } else {
@@ -37178,8 +37177,6 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37178
37177
  }
37179
37178
  const reInit = () => {
37180
37179
  const columns = getColumns();
37181
- plainOptions.value = columns;
37182
- cachePlainOptions.value = columns;
37183
37180
  vue.unref(plainOptions).forEach((item) => {
37184
37181
  const findItem = columns.find((col) => col.dataIndex === item.dataIndex);
37185
37182
  if (findItem) {
@@ -37187,17 +37184,16 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37187
37184
  item.width = findItem.width;
37188
37185
  }
37189
37186
  });
37190
- const data = getResult(columns);
37191
- emit("columns-change", data);
37187
+ handleEmit(columns, false);
37192
37188
  };
37193
37189
  function onCheckAllChange(e) {
37194
- const checkList = plainOptions.value.map((item) => item.value);
37190
+ const checkList = plainOptions.value.map((item) => item.dataIndex);
37195
37191
  if (e.target.checked) {
37196
37192
  state.checkedList = checkList;
37197
- setColumns(checkList);
37193
+ handleEmit(checkList);
37198
37194
  } else {
37199
37195
  state.checkedList = [];
37200
- setColumns([]);
37196
+ handleEmit([]);
37201
37197
  }
37202
37198
  }
37203
37199
  const indeterminate = vue.computed(() => {
@@ -37206,13 +37202,13 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37206
37202
  return checkedLen > 0 && checkedLen < len;
37207
37203
  });
37208
37204
  function onChange(checkedList) {
37209
- const len = plainSortOptions.value.length;
37205
+ const len = plainOptions.value.length;
37210
37206
  state.checkAll = checkedList.length === len;
37211
- const sortList = vue.unref(plainSortOptions).map((item) => item.value);
37207
+ const sortList = vue.unref(plainOptions).map((item) => item.dataIndex);
37212
37208
  checkedList.sort((prev2, next2) => {
37213
37209
  return sortList.indexOf(prev2) - sortList.indexOf(next2);
37214
37210
  });
37215
- setColumns(checkedList);
37211
+ handleEmit(checkedList);
37216
37212
  }
37217
37213
  let sortable;
37218
37214
  let sortableOrder = [];
@@ -37220,8 +37216,7 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37220
37216
  state.checkedList = [...state.defaultCheckList];
37221
37217
  state.checkAll = true;
37222
37218
  plainOptions.value = vue.unref(cachePlainOptions);
37223
- plainSortOptions.value = vue.unref(cachePlainOptions);
37224
- setColumns(table2.getCacheColumns());
37219
+ handleEmit(table2.getCacheColumns());
37225
37220
  sortable.sort(sortableOrder);
37226
37221
  }
37227
37222
  function handleVisibleChange() {
@@ -37247,7 +37242,7 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37247
37242
  if (utils.isNullAndUnDef(oldIndex) || utils.isNullAndUnDef(newIndex) || oldIndex === newIndex) {
37248
37243
  return;
37249
37244
  }
37250
- const columns = cloneDeep(plainSortOptions.value);
37245
+ const columns = cloneDeep(plainOptions.value);
37251
37246
  if (oldIndex > newIndex) {
37252
37247
  columns.splice(newIndex, 0, columns[oldIndex]);
37253
37248
  columns.splice(oldIndex + 1, 1);
@@ -37255,8 +37250,8 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37255
37250
  columns.splice(newIndex + 1, 0, columns[oldIndex]);
37256
37251
  columns.splice(oldIndex, 1);
37257
37252
  }
37258
- plainSortOptions.value = columns;
37259
- setColumns(columns.map((col) => col.value).filter((value) => state.checkedList.includes(value)));
37253
+ const tempCol = columns.map((col) => col.dataIndex).filter((value) => state.checkedList.includes(value));
37254
+ handleEmit(tempCol);
37260
37255
  }
37261
37256
  });
37262
37257
  sortableOrder = sortable.toArray();
@@ -37290,27 +37285,51 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37290
37285
  (_a2 = table2.setCacheColumnsByField) == null ? void 0 : _a2.call(table2, item.dataIndex, {
37291
37286
  fixed: isFixed
37292
37287
  });
37293
- setColumns(columns);
37288
+ handleEmit(columns);
37294
37289
  }
37295
37290
  function getResult(columns) {
37296
- return vue.unref(plainOptions).map((col) => {
37297
- const defaultHidden = columns.findIndex((c) => c === col.value || typeof c !== "string" && c.dataIndex === col.value && (isBoolean(c.defaultHidden) ? c.defaultHidden : false)) !== -1;
37291
+ const tempOptions = vue.unref(plainOptions).map((col) => {
37292
+ let defaultHidden = false;
37293
+ if (columns.every((val) => typeof val === "string")) {
37294
+ defaultHidden = columns.findIndex((val) => val === col.dataIndex) === -1;
37295
+ } else {
37296
+ const find = columns.find((val) => val.dataIndex === col.dataIndex);
37297
+ defaultHidden = find ? isBoolean(find.defaultHidden) ? find.defaultHidden : false : true;
37298
+ }
37298
37299
  return {
37299
- dataIndex: col.value,
37300
+ title: col.title,
37301
+ dataIndex: col.dataIndex,
37300
37302
  fixed: col.fixed,
37301
37303
  defaultHidden,
37302
37304
  width: col.width
37303
37305
  };
37304
37306
  });
37305
- }
37306
- function setColumns(columns) {
37307
- table2.setColumns(columns);
37308
- const data = getResult(columns);
37309
- emit("columns-change", data);
37307
+ if (!columns.every((val) => typeof val === "string")) {
37308
+ const sortList = columns.map((item) => item.dataIndex);
37309
+ tempOptions.sort((prev2, next2) => {
37310
+ return sortList.indexOf(prev2.dataIndex) - sortList.indexOf(next2.dataIndex);
37311
+ });
37312
+ return tempOptions;
37313
+ }
37314
+ tempOptions.sort((prev2, next2) => {
37315
+ return columns.indexOf(prev2.dataIndex) - columns.indexOf(next2.dataIndex);
37316
+ });
37317
+ return tempOptions;
37310
37318
  }
37311
37319
  function getPopupContainer2() {
37312
37320
  return utils.isFunction(attrs.getPopupContainer) ? attrs.getPopupContainer() : utils.getPopupContainer();
37313
37321
  }
37322
+ const handleEmit = useDebounceFn$1((columns, set2 = true) => {
37323
+ const data = getResult(columns);
37324
+ emit("columns-change", data);
37325
+ if (set2) {
37326
+ inset = true;
37327
+ table2.setColumns(columns);
37328
+ setTimeout(() => {
37329
+ inset = false;
37330
+ });
37331
+ }
37332
+ }, 100);
37314
37333
  return () => {
37315
37334
  return vue.createVNode(antDesignVue.Tooltip, {
37316
37335
  "placement": "top"
@@ -37366,9 +37385,9 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37366
37385
  }, [vue.createVNode(DragOutlined$1, {
37367
37386
  "class": "table-column-drag-icon"
37368
37387
  }, null), vue.createVNode(antDesignVue.Checkbox, {
37369
- "value": item.value
37388
+ "value": item.dataIndex
37370
37389
  }, {
37371
- default: () => [item.label]
37390
+ default: () => [item.title]
37372
37391
  }), vue.createVNode(antDesignVue.Tooltip, {
37373
37392
  "placement": "bottomLeft",
37374
37393
  "mouseLeaveDelay": 0.4,
@@ -37378,7 +37397,7 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37378
37397
  "rotate": 90,
37379
37398
  "class": [`${prefixCls2}__fixed-left`, {
37380
37399
  active: item.fixed === "left",
37381
- disabled: !state.checkedList.includes(item.value)
37400
+ disabled: !state.checkedList.includes(item.dataIndex)
37382
37401
  }],
37383
37402
  "onClick": () => handleColumnFixed(item, "left")
37384
37403
  }, null)],
@@ -37394,7 +37413,7 @@ const ShyTableColumn = /* @__PURE__ */ vue.defineComponent({
37394
37413
  "rotate": 90,
37395
37414
  "class": [`${prefixCls2}__fixed-right`, {
37396
37415
  active: item.fixed === "right",
37397
- disabled: !state.checkedList.includes(item.value)
37416
+ disabled: !state.checkedList.includes(item.dataIndex)
37398
37417
  }],
37399
37418
  "onClick": () => handleColumnFixed(item, "right")
37400
37419
  }, null)],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "3h1-ui",
3
- "version": "3.0.0-next.43",
3
+ "version": "3.0.0-next.45",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -29,9 +29,9 @@
29
29
  "vue-json-pretty": "^2.2.3",
30
30
  "vxe-table": "^4.3.6",
31
31
  "xe-utils": "^3.5.7",
32
+ "@shy-plugins/utils": "1.0.0-next.1",
32
33
  "@shy-plugins/tinymce": "^1.0.6",
33
- "@shy-plugins/use": "1.0.0-next.1",
34
- "@shy-plugins/utils": "1.0.0-next.1"
34
+ "@shy-plugins/use": "1.0.0-next.1"
35
35
  },
36
36
  "types": "es/ui/index.d.ts",
37
37
  "devDependencies": {
@@ -48,7 +48,6 @@
48
48
  "patch": "npm version patch",
49
49
  "deploy": "pnpm -v",
50
50
  "build": "vite build",
51
- "build:less": "esno build/buildLess",
52
- "update:version": "tsx ../../scripts/update-version.ts"
51
+ "build:less": "esno build/buildLess"
53
52
  }
54
53
  }