knt-shared 1.8.0 → 1.8.2

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
@@ -6065,6 +6065,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
6065
6065
  autoHeight: { type: Boolean, default: false },
6066
6066
  maxHeight: {},
6067
6067
  editConfig: {},
6068
+ emptyConfig: { type: [Boolean, String, Object] },
6068
6069
  columns: { default: () => [] },
6069
6070
  data: { default: () => [] },
6070
6071
  bordered: { type: Boolean, default: true },
@@ -6355,6 +6356,63 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
6355
6356
  });
6356
6357
  return map;
6357
6358
  });
6359
+ function normalizeEmptyConfig(raw) {
6360
+ if (raw === false) return false;
6361
+ if (raw === void 0) return void 0;
6362
+ if (typeof raw === "string") return { enabled: true, text: raw };
6363
+ return raw;
6364
+ }
6365
+ function resolveEmptyConfig(col) {
6366
+ const colRaw = normalizeEmptyConfig(col.emptyConfig);
6367
+ if (colRaw === false) return false;
6368
+ if (colRaw !== void 0) {
6369
+ return { enabled: true, text: "-", ...colRaw };
6370
+ }
6371
+ const tableRaw = normalizeEmptyConfig(
6372
+ getMergedProps.value.emptyConfig
6373
+ );
6374
+ if (tableRaw === false || tableRaw === void 0) return false;
6375
+ return { enabled: true, text: "-", ...tableRaw };
6376
+ }
6377
+ function resolveEllipsisEmptyConfig(col) {
6378
+ var _a;
6379
+ const ellipsis = (_a = originalColumnsMap.value.get(col.dataIndex)) == null ? void 0 : _a.ellipsis;
6380
+ if (ellipsis && typeof ellipsis === "object" && "emptyConfig" in ellipsis) {
6381
+ const ellipsisRaw = normalizeEmptyConfig(
6382
+ ellipsis.emptyConfig
6383
+ );
6384
+ if (ellipsisRaw === false) return false;
6385
+ if (ellipsisRaw !== void 0) return { enabled: true, text: "-", ...ellipsisRaw };
6386
+ }
6387
+ return resolveEmptyConfig(col);
6388
+ }
6389
+ function isEmptyValue(value, record, config) {
6390
+ const { emptyValues } = config;
6391
+ if (typeof emptyValues === "function") return emptyValues(value, record);
6392
+ const targets = emptyValues ?? ["null", "undefined", "emptyString"];
6393
+ return targets.includes("null") && value === null || targets.includes("undefined") && value === void 0 || targets.includes("emptyString") && value === "" || targets.includes("zero") && value === 0 || targets.includes("false") && value === false;
6394
+ }
6395
+ function resolveEmptyValue(value, record, col) {
6396
+ const config = resolveEmptyConfig(col);
6397
+ if (!config || config.enabled === false) return value;
6398
+ if (isEmptyValue(value, record, config)) return config.text ?? "-";
6399
+ return value;
6400
+ }
6401
+ function resolveEllipsisText(value, record, col) {
6402
+ const config = resolveEllipsisEmptyConfig(col);
6403
+ if (!config || config.enabled === false) return String(value ?? "");
6404
+ if (isEmptyValue(value, record, config)) return config.text ?? "-";
6405
+ return String(value ?? "");
6406
+ }
6407
+ function resolveEllipsisTooltip(value, record, col) {
6408
+ var _a;
6409
+ const config = resolveEllipsisEmptyConfig(col);
6410
+ const ellipsis = (_a = originalColumnsMap.value.get(col.dataIndex)) == null ? void 0 : _a.ellipsis;
6411
+ const configuredTooltip = ellipsis && typeof ellipsis === "object" ? ellipsis.tooltip ?? true : true;
6412
+ if (!config || config.enabled === false) return configuredTooltip;
6413
+ if (isEmptyValue(value, record, config)) return false;
6414
+ return configuredTooltip;
6415
+ }
6358
6416
  const getViewColumns = computed(() => {
6359
6417
  const mergedProps = getMergedProps.value;
6360
6418
  let columns = [...mergedProps.columns];
@@ -6707,7 +6765,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
6707
6765
  selectedRows.value = dedupeRowsByKey([...otherPagesRows, ...frozenRows]);
6708
6766
  }
6709
6767
  }
6710
- emit("selectAll", checked);
6768
+ emit("selectAll", checked, selectableRows, selectableKeys);
6711
6769
  };
6712
6770
  const handleExpand = (record, expanded) => {
6713
6771
  emit("expand", record, expanded);
@@ -7424,20 +7482,24 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
7424
7482
  "edit-config": props.editConfig,
7425
7483
  onChange: (val) => unref(setEditValue)(slotProps.record, col, val)
7426
7484
  }, null, 8, ["column", "record", "row-index", "value", "error", "edit-config", "onChange"])) : _ctx.$slots[col.dataIndex] ? renderSlot(_ctx.$slots, col.dataIndex, normalizeProps(mergeProps({ key: 3 }, slotProps)), void 0, true) : col.customRender ? (openBlock(), createBlock(resolveDynamicComponent(renderCustomCell(col, slotProps)), { key: 4 })) : col.format ? (openBlock(), createElementBlock(Fragment, { key: 5 }, [
7427
- createTextVNode(toDisplayString(col.format(
7428
- slotProps.record[col.dataIndex],
7485
+ createTextVNode(toDisplayString(resolveEmptyValue(
7486
+ col.format(
7487
+ slotProps.record[col.dataIndex],
7488
+ slotProps.record,
7489
+ slotProps.rowIndex
7490
+ ),
7429
7491
  slotProps.record,
7430
- slotProps.rowIndex
7492
+ col
7431
7493
  )), 1)
7432
7494
  ], 64)) : col.dataIndex && ((_a = originalColumnsMap.value.get(col.dataIndex)) == null ? void 0 : _a.ellipsis) && typeof ((_b = originalColumnsMap.value.get(col.dataIndex)) == null ? void 0 : _b.ellipsis) === "object" ? (openBlock(), createBlock(unref(BasicTextEllipsis), {
7433
7495
  key: 6,
7434
- text: String(slotProps.record[col.dataIndex] ?? ""),
7496
+ text: resolveEllipsisText(slotProps.record[col.dataIndex], slotProps.record, col),
7435
7497
  lines: originalColumnsMap.value.get(col.dataIndex).ellipsis.lines ?? 1,
7436
- tooltip: originalColumnsMap.value.get(col.dataIndex).ellipsis.tooltip ?? true,
7498
+ tooltip: resolveEllipsisTooltip(slotProps.record[col.dataIndex], slotProps.record, col),
7437
7499
  tooltipTrigger: originalColumnsMap.value.get(col.dataIndex).ellipsis.tooltipTrigger ?? "hover",
7438
7500
  tooltipProps: originalColumnsMap.value.get(col.dataIndex).ellipsis.tooltipProps
7439
7501
  }, null, 8, ["text", "lines", "tooltip", "tooltipTrigger", "tooltipProps"])) : (openBlock(), createElementBlock(Fragment, { key: 7 }, [
7440
- createTextVNode(toDisplayString(slotProps.record[col.dataIndex]), 1)
7502
+ createTextVNode(toDisplayString(resolveEmptyValue(slotProps.record[col.dataIndex], slotProps.record, col)), 1)
7441
7503
  ], 64))
7442
7504
  ];
7443
7505
  })
@@ -7448,7 +7510,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
7448
7510
  };
7449
7511
  }
7450
7512
  });
7451
- const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-4e9be0fe"]]);
7513
+ const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-84dbe67a"]]);
7452
7514
  function useTable(options = {}) {
7453
7515
  const tableRef = ref(null);
7454
7516
  const formRef = ref(null);