knt-shared 1.8.7 → 1.8.9

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
@@ -4244,6 +4244,21 @@ const componentsNeedSelectPlaceholder$1 = /* @__PURE__ */ new Set([
4244
4244
  "ApiCascader",
4245
4245
  "TreeSelect"
4246
4246
  ]);
4247
+ const componentsWithAllowClear = /* @__PURE__ */ new Set([
4248
+ "Input",
4249
+ "InputNumber",
4250
+ "InputPassword",
4251
+ "Textarea",
4252
+ "Select",
4253
+ "TreeSelect",
4254
+ "Cascader",
4255
+ "DatePicker",
4256
+ "TimePicker",
4257
+ "RangePicker",
4258
+ "AutoComplete",
4259
+ "ApiSelect",
4260
+ "ApiCascader"
4261
+ ]);
4247
4262
  const componentsNeedUploadPlaceholder$1 = /* @__PURE__ */ new Set([
4248
4263
  "Upload",
4249
4264
  "BasicUpload"
@@ -5144,11 +5159,14 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
5144
5159
  };
5145
5160
  const getComponentProps = (schema) => {
5146
5161
  const propsData = unref(getProps);
5162
+ const componentType = typeof schema.component === "string" ? schema.component : "";
5163
+ const defaultAllowClear = componentsWithAllowClear.has(componentType) ? { allowClear: true } : {};
5147
5164
  let disabled = propsData.disabled;
5148
5165
  if (schema.disabled !== void 0) {
5149
5166
  disabled = typeof schema.disabled === "boolean" ? schema.disabled : schema.disabled(formModel);
5150
5167
  }
5151
5168
  return {
5169
+ ...defaultAllowClear,
5152
5170
  ...resolveComponentProps(schema),
5153
5171
  disabled
5154
5172
  };
@@ -7188,7 +7206,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
7188
7206
  return raw;
7189
7207
  }
7190
7208
  function resolveEmptyConfig(col) {
7191
- const colRaw = normalizeEmptyConfig(col.emptyConfig);
7209
+ const colRaw = normalizeEmptyConfig(
7210
+ col.emptyConfig
7211
+ );
7192
7212
  if (colRaw === false) return false;
7193
7213
  if (colRaw !== void 0) {
7194
7214
  return { enabled: true, text: "-", ...colRaw };
@@ -7201,13 +7221,16 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
7201
7221
  }
7202
7222
  function resolveEllipsisEmptyConfig(col) {
7203
7223
  var _a;
7204
- const ellipsis = (_a = originalColumnsMap.value.get(col.dataIndex)) == null ? void 0 : _a.ellipsis;
7224
+ const ellipsis = (_a = originalColumnsMap.value.get(
7225
+ col.dataIndex
7226
+ )) == null ? void 0 : _a.ellipsis;
7205
7227
  if (ellipsis && typeof ellipsis === "object" && "emptyConfig" in ellipsis) {
7206
7228
  const ellipsisRaw = normalizeEmptyConfig(
7207
7229
  ellipsis.emptyConfig
7208
7230
  );
7209
7231
  if (ellipsisRaw === false) return false;
7210
- if (ellipsisRaw !== void 0) return { enabled: true, text: "-", ...ellipsisRaw };
7232
+ if (ellipsisRaw !== void 0)
7233
+ return { enabled: true, text: "-", ...ellipsisRaw };
7211
7234
  }
7212
7235
  return resolveEmptyConfig(col);
7213
7236
  }
@@ -7232,7 +7255,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
7232
7255
  function resolveEllipsisTooltip(value, record, col) {
7233
7256
  var _a;
7234
7257
  const config = resolveEllipsisEmptyConfig(col);
7235
- const ellipsis = (_a = originalColumnsMap.value.get(col.dataIndex)) == null ? void 0 : _a.ellipsis;
7258
+ const ellipsis = (_a = originalColumnsMap.value.get(
7259
+ col.dataIndex
7260
+ )) == null ? void 0 : _a.ellipsis;
7236
7261
  const configuredTooltip = ellipsis && typeof ellipsis === "object" ? ellipsis.tooltip ?? true : true;
7237
7262
  if (!config || config.enabled === false) return configuredTooltip;
7238
7263
  if (isEmptyValue(value, record, config)) return false;
@@ -7301,7 +7326,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
7301
7326
  watch(settingColumns, (newCols) => {
7302
7327
  if (!isColumnSettingReady.value) return;
7303
7328
  const currentKeys = new Set(checkedColumns.value);
7304
- const newKeys = newCols.filter((col) => col.dataIndex && !currentKeys.has(col.dataIndex)).map((col) => col.dataIndex);
7329
+ const newKeys = newCols.filter(
7330
+ (col) => col.dataIndex && !currentKeys.has(col.dataIndex)
7331
+ ).map((col) => col.dataIndex);
7305
7332
  if (newKeys.length > 0) {
7306
7333
  checkedColumns.value = [...checkedColumns.value, ...newKeys];
7307
7334
  }
@@ -7351,7 +7378,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
7351
7378
  }
7352
7379
  return (pagination.current - 1) * pagination.pageSize + rowIndex + 1;
7353
7380
  };
7354
- const showConfirmModal = (action, record) => {
7381
+ const showConfirmModal = (action, slotProps) => {
7355
7382
  Modal.confirm({
7356
7383
  title: action.popConfirm.title,
7357
7384
  content: action.popConfirm.content,
@@ -7359,7 +7386,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
7359
7386
  cancelText: action.popConfirm.cancelText,
7360
7387
  onOk: () => {
7361
7388
  var _a, _b;
7362
- return (_b = (_a = action.popConfirm).onConfirm) == null ? void 0 : _b.call(_a, record);
7389
+ return (_b = (_a = action.popConfirm).onConfirm) == null ? void 0 : _b.call(_a, slotProps);
7363
7390
  },
7364
7391
  onCancel: action.popConfirm.onCancel
7365
7392
  });
@@ -7407,9 +7434,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
7407
7434
  }
7408
7435
  return action.disabled || false;
7409
7436
  };
7410
- const handleActionClick = (action, record) => {
7437
+ const handleActionClick = (action, slotProps) => {
7411
7438
  if (action.onClick) {
7412
- action.onClick(record);
7439
+ action.onClick(slotProps);
7413
7440
  }
7414
7441
  };
7415
7442
  const handleTableChange = (data, extra, currentData) => {
@@ -7592,9 +7619,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
7592
7619
  ...selectableRows
7593
7620
  ]);
7594
7621
  } else {
7595
- selectedRowKeys.value = [
7596
- .../* @__PURE__ */ new Set([...otherPagesKeys, ...frozenKeys])
7597
- ];
7622
+ selectedRowKeys.value = [.../* @__PURE__ */ new Set([...otherPagesKeys, ...frozenKeys])];
7598
7623
  selectedRows.value = dedupeRowsByKey([...otherPagesRows, ...frozenRows]);
7599
7624
  }
7600
7625
  }
@@ -8210,7 +8235,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
8210
8235
  "cancel-text": action.popConfirm.cancelText,
8211
8236
  onOk: ($event) => {
8212
8237
  var _a2, _b2;
8213
- return (_b2 = (_a2 = action.popConfirm).onConfirm) == null ? void 0 : _b2.call(_a2, slotProps.record);
8238
+ return (_b2 = (_a2 = action.popConfirm).onConfirm) == null ? void 0 : _b2.call(_a2, slotProps);
8214
8239
  },
8215
8240
  onCancel: action.popConfirm.onCancel
8216
8241
  }, {
@@ -8240,7 +8265,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
8240
8265
  key: 1,
8241
8266
  status: action.color,
8242
8267
  disabled: getActionDisabled(action, slotProps.record),
8243
- onClick: ($event) => handleActionClick(action, slotProps.record)
8268
+ onClick: ($event) => handleActionClick(action, slotProps)
8244
8269
  }, createSlots({
8245
8270
  default: withCtx(() => [
8246
8271
  createTextVNode(" " + toDisplayString(action.label), 1)
@@ -8266,7 +8291,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
8266
8291
  action.popConfirm ? (openBlock(), createBlock(unref(Doption), {
8267
8292
  key: 0,
8268
8293
  disabled: getActionDisabled(action, slotProps.record),
8269
- onClick: () => showConfirmModal(action, slotProps.record)
8294
+ onClick: () => showConfirmModal(action, slotProps)
8270
8295
  }, {
8271
8296
  default: withCtx(() => [
8272
8297
  createTextVNode(toDisplayString(action.label), 1)
@@ -8275,7 +8300,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
8275
8300
  }, 1032, ["disabled", "onClick"])) : (openBlock(), createBlock(unref(Doption), {
8276
8301
  key: 1,
8277
8302
  disabled: getActionDisabled(action, slotProps.record),
8278
- onClick: ($event) => handleActionClick(action, slotProps.record)
8303
+ onClick: ($event) => handleActionClick(action, slotProps)
8279
8304
  }, createSlots({
8280
8305
  default: withCtx(() => [
8281
8306
  createTextVNode(" " + toDisplayString(action.label), 1)
@@ -8327,13 +8352,25 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
8327
8352
  )), 1)
8328
8353
  ], 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), {
8329
8354
  key: 6,
8330
- text: resolveEllipsisText(slotProps.record[col.dataIndex], slotProps.record, col),
8355
+ text: resolveEllipsisText(
8356
+ slotProps.record[col.dataIndex],
8357
+ slotProps.record,
8358
+ col
8359
+ ),
8331
8360
  lines: originalColumnsMap.value.get(col.dataIndex).ellipsis.lines ?? 1,
8332
- tooltip: resolveEllipsisTooltip(slotProps.record[col.dataIndex], slotProps.record, col),
8361
+ tooltip: resolveEllipsisTooltip(
8362
+ slotProps.record[col.dataIndex],
8363
+ slotProps.record,
8364
+ col
8365
+ ),
8333
8366
  tooltipTrigger: originalColumnsMap.value.get(col.dataIndex).ellipsis.tooltipTrigger ?? "hover",
8334
8367
  tooltipProps: originalColumnsMap.value.get(col.dataIndex).ellipsis.tooltipProps
8335
8368
  }, null, 8, ["text", "lines", "tooltip", "tooltipTrigger", "tooltipProps"])) : (openBlock(), createElementBlock(Fragment, { key: 7 }, [
8336
- createTextVNode(toDisplayString(resolveEmptyValue(slotProps.record[col.dataIndex], slotProps.record, col)), 1)
8369
+ createTextVNode(toDisplayString(resolveEmptyValue(
8370
+ slotProps.record[col.dataIndex],
8371
+ slotProps.record,
8372
+ col
8373
+ )), 1)
8337
8374
  ], 64))
8338
8375
  ];
8339
8376
  })
@@ -8344,7 +8381,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
8344
8381
  };
8345
8382
  }
8346
8383
  });
8347
- const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-f752ab5b"]]);
8384
+ const BasicTable = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["__scopeId", "data-v-5f63dbb6"]]);
8348
8385
  function useTable(options = {}) {
8349
8386
  const tableRef = ref(null);
8350
8387
  const formRef = ref(null);