knt-shared 1.10.6 → 1.10.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"BasicImage.vue.d.ts","sourceRoot":"","sources":["../../../src/components/Image/BasicImage.vue"],"names":[],"mappings":"AA4DA;AAIA,OAAO,KAAK,EACV,eAAe,EAEf,SAAS,EACT,YAAY,EACb,MAAM,SAAS,CAAC;AAiKjB,iBAAS,cAAc;mBAgNK,GAAG;EAG9B;AAeD,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EAQnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAAvG,wBAAwG;AACxG,KAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,KAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC;AAC9M,KAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAE1B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QACxE,OAAO,EAAE,CAAC,CAAC,CAAC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E,CAAC,IAAI;KAE1B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG;QACxE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KACb,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CACT,CAAC;AACN,KAAK,cAAc,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC;AACxD,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,QAAO;QAClD,MAAM,EAAE,CAAC,CAAC;KACT,CAAA;CAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useImage.d.ts","sourceRoot":"","sources":["../../../src/components/Image/useImage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAIf,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,cAAc,CAyFlE"}
1
+ {"version":3,"file":"useImage.d.ts","sourceRoot":"","sources":["../../../src/components/Image/useImage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EAIf,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,cAAc,CAwFlE"}
package/dist/index.cjs.js CHANGED
@@ -2460,7 +2460,7 @@ const _hoisted_4$4 = {
2460
2460
  const _hoisted_5$4 = { class: "progress-bar" };
2461
2461
  const _hoisted_6$3 = { class: "controls-bottom" };
2462
2462
  const _hoisted_7$2 = { class: "controls-left" };
2463
- const _hoisted_8$1 = { class: "volume-slider-container" };
2463
+ const _hoisted_8$2 = { class: "volume-slider-container" };
2464
2464
  const _hoisted_9 = { class: "time-display" };
2465
2465
  const _hoisted_10 = { class: "controls-right" };
2466
2466
  const _hoisted_11 = { class: "control-button" };
@@ -2748,7 +2748,7 @@ const _sfc_main$h = /* @__PURE__ */ vue.defineComponent({
2748
2748
  size: 20
2749
2749
  }))
2750
2750
  ]),
2751
- vue.withDirectives(vue.createElementVNode("div", _hoisted_8$1, [
2751
+ vue.withDirectives(vue.createElementVNode("div", _hoisted_8$2, [
2752
2752
  vue.withDirectives(vue.createElementVNode("input", {
2753
2753
  "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => volume.value = $event),
2754
2754
  type: "range",
@@ -2908,7 +2908,7 @@ const _hoisted_7$1 = {
2908
2908
  key: 1,
2909
2909
  class: "upload-tip sortable-tip"
2910
2910
  };
2911
- const _hoisted_8 = {
2911
+ const _hoisted_8$1 = {
2912
2912
  key: 5,
2913
2913
  class: "inline-video-preview"
2914
2914
  };
@@ -3634,7 +3634,7 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
3634
3634
  "file-name": previewFileName.value,
3635
3635
  "player-options": getProps.value.videoPlayerOptions
3636
3636
  }, null, 8, ["visible", "video-url", "file-name", "player-options"])) : vue.createCommentVNode("", true),
3637
- getProps.value.videoPreviewMode === "inline" && previewVideoVisible.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_8, [
3637
+ getProps.value.videoPreviewMode === "inline" && previewVideoVisible.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_8$1, [
3638
3638
  vue.createVNode(VideoPreview, {
3639
3639
  "video-url": previewVideoUrl.value,
3640
3640
  "player-options": getProps.value.videoPlayerOptions
@@ -10199,17 +10199,17 @@ function useDescription(props) {
10199
10199
  }
10200
10200
  ];
10201
10201
  }
10202
- const _hoisted_1$2 = { class: "basic-image" };
10203
- const _hoisted_2$1 = {
10202
+ const _hoisted_1$2 = {
10204
10203
  key: 0,
10205
10204
  class: "basic-image-empty"
10206
10205
  };
10207
- const _hoisted_3$1 = { class: "empty-text" };
10208
- const _hoisted_4 = {
10206
+ const _hoisted_2$1 = { class: "empty-text" };
10207
+ const _hoisted_3$1 = {
10209
10208
  key: 0,
10210
10209
  class: "basic-image-simple"
10211
10210
  };
10212
- const _hoisted_5 = { class: "image-wrapper" };
10211
+ const _hoisted_4 = { class: "image-wrapper" };
10212
+ const _hoisted_5 = ["src", "width", "height", "alt"];
10213
10213
  const _hoisted_6 = {
10214
10214
  key: 0,
10215
10215
  class: "image-count-badge"
@@ -10218,6 +10218,7 @@ const _hoisted_7 = {
10218
10218
  key: 0,
10219
10219
  style: { "display": "none" }
10220
10220
  };
10221
+ const _hoisted_8 = ["src", "width", "height", "alt"];
10221
10222
  const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
10222
10223
  ...{
10223
10224
  name: "BasicImage"
@@ -10245,21 +10246,45 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
10245
10246
  const getProps = vue.computed(() => {
10246
10247
  return { ...props, ...innerPropsRef.value };
10247
10248
  });
10249
+ function isSafeImageUrl(url) {
10250
+ if (!url || typeof url !== "string") return false;
10251
+ const trimmed = url.trim();
10252
+ if (trimmed.startsWith("/") || trimmed.startsWith("./") || trimmed.startsWith("../")) {
10253
+ return true;
10254
+ }
10255
+ if (/^data:/i.test(trimmed)) {
10256
+ return /^data:image\/(?!svg\+xml)/i.test(trimmed);
10257
+ }
10258
+ try {
10259
+ const { protocol } = new URL(trimmed);
10260
+ return protocol === "http:" || protocol === "https:" || protocol === "blob:";
10261
+ } catch {
10262
+ return false;
10263
+ }
10264
+ }
10248
10265
  const normalizedImages = vue.computed(() => {
10249
10266
  const images = getProps.value.images || [];
10250
10267
  if (!Array.isArray(images) || images.length === 0) {
10251
10268
  return [];
10252
10269
  }
10253
10270
  return images.map((item) => {
10254
- if (typeof item === "string") {
10255
- return { url: item };
10271
+ const normalized = typeof item === "string" ? { url: item } : item;
10272
+ if (!isSafeImageUrl(normalized.url)) {
10273
+ return { ...normalized, url: "" };
10256
10274
  }
10257
- return item;
10275
+ return normalized;
10258
10276
  });
10259
10277
  });
10278
+ const safeErrorImage = vue.computed(() => {
10279
+ const url = getProps.value.errorImage;
10280
+ if (!url || !isSafeImageUrl(url)) return void 0;
10281
+ return url;
10282
+ });
10260
10283
  const gridStyle = vue.computed(() => {
10284
+ const rawGap = getProps.value.gap ?? 8;
10285
+ const gap = Number.isFinite(rawGap) ? Math.max(0, rawGap) : 8;
10261
10286
  return {
10262
- gap: `${getProps.value.gap}px`
10287
+ gap: `${gap}px`
10263
10288
  };
10264
10289
  });
10265
10290
  const handleImageClick = (item, index) => {
@@ -10267,6 +10292,9 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
10267
10292
  return;
10268
10293
  }
10269
10294
  emit("click", item, index);
10295
+ if (getProps.value.preview) {
10296
+ emit("preview", item, index);
10297
+ }
10270
10298
  };
10271
10299
  const getImages = () => {
10272
10300
  return normalizedImages.value;
@@ -10286,41 +10314,52 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
10286
10314
  getProps: getPropsValue,
10287
10315
  setProps
10288
10316
  };
10289
- vue.watch(
10290
- () => props,
10291
- () => {
10292
- },
10293
- { deep: true }
10294
- );
10295
10317
  vue.onMounted(() => {
10296
10318
  emit("register", methods);
10297
10319
  });
10298
10320
  __expose(methods);
10299
10321
  return (_ctx, _cache) => {
10300
- return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
10301
- normalizedImages.value.length === 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$1, [
10322
+ return vue.openBlock(), vue.createElementBlock("div", {
10323
+ class: vue.normalizeClass(["basic-image", { "basic-image--disabled": getProps.value.disabled }])
10324
+ }, [
10325
+ normalizedImages.value.length === 0 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$2, [
10302
10326
  vue.renderSlot(_ctx.$slots, "empty", {}, () => [
10303
- vue.createElementVNode("span", _hoisted_3$1, vue.toDisplayString(getProps.value.emptyText), 1)
10327
+ vue.createElementVNode("span", _hoisted_2$1, vue.toDisplayString(getProps.value.emptyText), 1)
10304
10328
  ], true)
10305
10329
  ])) : (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(getProps.value.preview ? vue.unref(ArcoVue.ImagePreviewGroup) : "div"), { key: 1 }, {
10306
10330
  default: vue.withCtx(() => [
10307
- !getProps.value.showAll ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4, [
10308
- vue.createElementVNode("div", _hoisted_5, [
10331
+ !getProps.value.showAll ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$1, [
10332
+ vue.createElementVNode("div", _hoisted_4, [
10309
10333
  vue.createVNode(vue.unref(ArcoVue.Image), {
10310
10334
  src: normalizedImages.value[0].url,
10311
10335
  width: getProps.value.width,
10312
10336
  height: getProps.value.height,
10313
10337
  fit: getProps.value.fit,
10314
10338
  preview: getProps.value.preview,
10339
+ "show-loader": getProps.value.loading,
10315
10340
  alt: normalizedImages.value[0].name || "图片",
10316
10341
  onClick: _cache[0] || (_cache[0] = ($event) => handleImageClick(normalizedImages.value[0], 0))
10317
- }, null, 8, ["src", "width", "height", "fit", "preview", "alt"]),
10318
- normalizedImages.value.length > 1 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6, " +" + vue.toDisplayString(normalizedImages.value.length - 1), 1)) : vue.createCommentVNode("", true)
10342
+ }, vue.createSlots({ _: 2 }, [
10343
+ safeErrorImage.value ? {
10344
+ name: "error",
10345
+ fn: vue.withCtx(() => [
10346
+ vue.createElementVNode("img", {
10347
+ src: safeErrorImage.value,
10348
+ width: getProps.value.width,
10349
+ height: getProps.value.height,
10350
+ style: vue.normalizeStyle({ display: "block", objectFit: getProps.value.fit }),
10351
+ alt: normalizedImages.value[0].name || "图片"
10352
+ }, null, 12, _hoisted_5)
10353
+ ]),
10354
+ key: "0"
10355
+ } : void 0
10356
+ ]), 1032, ["src", "width", "height", "fit", "preview", "show-loader", "alt"]),
10357
+ normalizedImages.value.length > (getProps.value.maxCount ?? 1) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6, " +" + vue.toDisplayString(normalizedImages.value.length - (getProps.value.maxCount ?? 1)), 1)) : vue.createCommentVNode("", true)
10319
10358
  ]),
10320
- getProps.value.preview && normalizedImages.value.length > 1 ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7, [
10321
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(normalizedImages.value.slice(1), (item, index) => {
10359
+ getProps.value.preview && normalizedImages.value.length > (getProps.value.maxCount ?? 1) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_7, [
10360
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(normalizedImages.value.slice(getProps.value.maxCount ?? 1), (item, index) => {
10322
10361
  return vue.openBlock(), vue.createBlock(vue.unref(ArcoVue.Image), {
10323
- key: index,
10362
+ key: `${item.url}-${index}`,
10324
10363
  src: item.url,
10325
10364
  alt: item.name || "图片"
10326
10365
  }, null, 8, ["src", "alt"]);
@@ -10333,7 +10372,7 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
10333
10372
  }, [
10334
10373
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(normalizedImages.value, (item, index) => {
10335
10374
  return vue.openBlock(), vue.createElementBlock("div", {
10336
- key: index,
10375
+ key: `${item.url}-${index}`,
10337
10376
  class: "image-item"
10338
10377
  }, [
10339
10378
  vue.createVNode(vue.unref(ArcoVue.Image), {
@@ -10342,33 +10381,46 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
10342
10381
  height: getProps.value.height,
10343
10382
  fit: getProps.value.fit,
10344
10383
  preview: getProps.value.preview,
10384
+ "show-loader": getProps.value.loading,
10345
10385
  alt: item.name || "图片",
10346
10386
  onClick: ($event) => handleImageClick(item, index)
10347
- }, null, 8, ["src", "width", "height", "fit", "preview", "alt", "onClick"])
10387
+ }, vue.createSlots({ _: 2 }, [
10388
+ safeErrorImage.value ? {
10389
+ name: "error",
10390
+ fn: vue.withCtx(() => [
10391
+ vue.createElementVNode("img", {
10392
+ src: safeErrorImage.value,
10393
+ width: getProps.value.width,
10394
+ height: getProps.value.height,
10395
+ style: vue.normalizeStyle({ display: "block", objectFit: getProps.value.fit }),
10396
+ alt: item.name || "图片"
10397
+ }, null, 12, _hoisted_8)
10398
+ ]),
10399
+ key: "0"
10400
+ } : void 0
10401
+ ]), 1032, ["src", "width", "height", "fit", "preview", "show-loader", "alt", "onClick"])
10348
10402
  ]);
10349
10403
  }), 128))
10350
10404
  ], 4))
10351
10405
  ]),
10352
10406
  _: 1
10353
10407
  }))
10354
- ]);
10408
+ ], 2);
10355
10409
  };
10356
10410
  }
10357
10411
  });
10358
- const BasicImage = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-04c54d5a"]]);
10412
+ const BasicImage = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-71d2eff3"]]);
10359
10413
  function useImage(options) {
10360
10414
  const imageRef = vue.ref(null);
10361
10415
  const loadedRef = vue.ref(false);
10362
10416
  const register = (instance) => {
10363
- if (vue.unref(imageRef) && instance === vue.unref(imageRef)) {
10417
+ if (instance === vue.unref(imageRef)) {
10364
10418
  return;
10365
10419
  }
10366
10420
  imageRef.value = instance;
10367
10421
  loadedRef.value = true;
10368
10422
  if (options) {
10369
- vue.nextTick(() => {
10370
- instance.setProps(options);
10371
- });
10423
+ instance.setProps(options);
10372
10424
  }
10373
10425
  };
10374
10426
  const getInstance = () => {