@deot/vc-components 1.0.51 → 1.0.52

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.cjs CHANGED
@@ -2383,23 +2383,23 @@ const InputNumber = /* @__PURE__ */ vue.defineComponent({
2383
2383
  ...listeners
2384
2384
  }), {
2385
2385
  prepend: slots.prepend && (() => slots.prepend?.()),
2386
- append: props.step ? slots.append ? () => slots.append?.() : () => {
2386
+ append: slots.append ? () => slots.append?.() : props.step ? () => {
2387
2387
  return vue.createVNode("div", {
2388
2388
  "class": "vc-input-number__icon"
2389
2389
  }, [vue.createVNode("div", {
2390
2390
  "class": "vc-input-number__up",
2391
- "disabled": plusDisabled.value ? 'disabled' : undefined,
2391
+ "disabled": plusDisabled.value ? 'disabled' : void 0,
2392
2392
  "onClick": e => handleStepper(e, 1)
2393
2393
  }, [vue.createVNode(Icon, {
2394
2394
  "type": "up"
2395
2395
  }, null)]), vue.createVNode("div", {
2396
2396
  "class": "vc-input-number__down",
2397
- "disabled": minusDisabled.value ? 'disabled' : undefined,
2397
+ "disabled": minusDisabled.value ? 'disabled' : void 0,
2398
2398
  "onClick": e => handleStepper(e, -1)
2399
2399
  }, [vue.createVNode(Icon, {
2400
2400
  "type": "down"
2401
2401
  }, null)])]);
2402
- } : undefined
2402
+ } : void 0
2403
2403
  });
2404
2404
  };
2405
2405
  }
@@ -12114,27 +12114,109 @@ const props$H = {
12114
12114
  tag: {
12115
12115
  type: String,
12116
12116
  default: "div"
12117
+ },
12118
+ // useCORS
12119
+ crossOrigin: {
12120
+ type: String,
12121
+ // ''. 'anonymous', 'use-credentials'
12122
+ default: "anonymous",
12123
+ validator: (v) => /^(|anonymous|use-credentials)$/.test(v)
12124
+ },
12125
+ transformSource: Function,
12126
+ // 传递给snap-dom的配置项
12127
+ options: {
12128
+ type: Object,
12129
+ default: () => ({})
12117
12130
  }
12118
12131
  };
12119
12132
 
12120
12133
  /** @jsxImportSource vue */
12121
12134
 
12122
- const COMPONENT_NAME$Z = 'vc-html-to-image';
12123
- const HTMLToImage = /* @__PURE__ */ vue.defineComponent({
12135
+ const COMPONENT_NAME$Z = 'vc-snapshot';
12136
+ const Snapshot = /* @__PURE__ */ vue.defineComponent({
12124
12137
  name: COMPONENT_NAME$Z,
12125
12138
  props: props$H,
12139
+ emits: ['ready'],
12126
12140
  setup(props, {
12127
- slots
12141
+ emit,
12142
+ slots,
12143
+ expose
12128
12144
  }) {
12145
+ const current = vue.ref();
12146
+ const instance = vue.ref();
12147
+
12148
+ // 网络的图片如果没有加上crossOrigin,且没有放在第一个就会出现问题(Safari)
12149
+ const refresh = async () => {
12150
+ if (!props.crossOrigin) return;
12151
+ const transformSource = props.transformSource || VcInstance.options.Snapshot?.transformSource || (v => v);
12152
+ return Promise.all(Array.from(current.value.querySelectorAll('img')).map(node => {
12153
+ return new Promise(resolve => {
12154
+ (async () => {
12155
+ let url;
12156
+ try {
12157
+ url = await transformSource(node.src);
12158
+ } catch (e) {
12159
+ console.error(e);
12160
+ }
12161
+ const image = new Image();
12162
+ image.crossOrigin = props.crossOrigin;
12163
+ image.src = `${url}?=${new Date().getTime()}`; // 强制不缓存
12164
+ image.onload = () => {
12165
+ node.src = image.src;
12166
+ resolve(1);
12167
+ };
12168
+ image.onerror = () => resolve(0);
12169
+ })();
12170
+ });
12171
+ }));
12172
+ };
12173
+ const toDataURL = async () => {
12174
+ await refresh();
12175
+ return instance.value.toRaw();
12176
+ };
12177
+ const download = async options => {
12178
+ await refresh();
12179
+ const _download = VcInstance.options.Snapshot?.download || (() => false);
12180
+ const allow = _download(options);
12181
+ if (allow && allow.then) {
12182
+ allow.catch(() => {
12183
+ instance.value.download(options);
12184
+ });
12185
+ return;
12186
+ }
12187
+ allow || instance.value.download(options);
12188
+ };
12189
+ expose({
12190
+ instance,
12191
+ refresh,
12192
+ toDataURL,
12193
+ download
12194
+ });
12195
+ vue.onMounted(async () => {
12196
+ try {
12197
+ let snapDOM = window.snapdom || (await import('@zumer/snapdom'));
12198
+ snapDOM = snapDOM.snapdom || snapDOM;
12199
+ instance.value = await snapDOM(current.value, props.options);
12200
+ emit('ready', {
12201
+ instance: instance.value,
12202
+ dependencies: {
12203
+ snapDOM
12204
+ }
12205
+ });
12206
+ } catch (e) {
12207
+ throw new VcError('snapshot', e);
12208
+ }
12209
+ });
12129
12210
  return () => {
12130
12211
  return vue.createVNode("div", {
12131
- "class": "vc-html-to-image"
12212
+ "ref": current,
12213
+ "class": "vc-snapshot"
12132
12214
  }, [slots?.default?.()]);
12133
12215
  };
12134
12216
  }
12135
12217
  });
12136
12218
 
12137
- const MHTMLToImage = HTMLToImage;
12219
+ const MSnapshot = Snapshot;
12138
12220
 
12139
12221
  const MIcon = Icon;
12140
12222
 
@@ -23962,7 +24044,6 @@ exports.Expand = Expand$1;
23962
24044
  exports.Form = Form;
23963
24045
  exports.FormItem = FormItem;
23964
24046
  exports.Fragment = Fragment;
23965
- exports.HTMLToImage = HTMLToImage;
23966
24047
  exports.Icon = Icon;
23967
24048
  exports.IconManager = IconManager;
23968
24049
  exports.Image = Image$1;
@@ -24007,7 +24088,6 @@ exports.MExpand = MExpand;
24007
24088
  exports.MForm = MForm;
24008
24089
  exports.MFormItem = MFormItem;
24009
24090
  exports.MFragment = MFragment;
24010
- exports.MHTMLToImage = MHTMLToImage;
24011
24091
  exports.MIcon = MIcon;
24012
24092
  exports.MImage = MImage;
24013
24093
  exports.MImageCrop = MImageCrop;
@@ -24041,6 +24121,7 @@ exports.MResizer = MResizer;
24041
24121
  exports.MScroller = MScroller;
24042
24122
  exports.MSelect = MSelect;
24043
24123
  exports.MSlider = MSlider;
24124
+ exports.MSnapshot = MSnapshot;
24044
24125
  exports.MSortList = MSortList;
24045
24126
  exports.MSpin = MSpin;
24046
24127
  exports.MSteps = MSteps;
@@ -24094,6 +24175,7 @@ exports.Scroller = Scroller;
24094
24175
  exports.ScrollerWheel = ScrollerWheel;
24095
24176
  exports.Select = Select;
24096
24177
  exports.Slider = Slider;
24178
+ exports.Snapshot = Snapshot;
24097
24179
  exports.SortList = SortList;
24098
24180
  exports.Spin = Spin;
24099
24181
  exports.Steps = Steps;
package/dist/index.d.ts CHANGED
@@ -2082,20 +2082,6 @@ export declare const Fragment: DefineComponent< {}, () => VNode<RendererNode,
2082
2082
  [key: string]: any;
2083
2083
  }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
2084
2084
 
2085
- export declare const HTMLToImage: DefineComponent<ExtractPropTypes< {
2086
- tag: {
2087
- type: StringConstructor;
2088
- default: string;
2089
- };
2090
- }>, () => JSX_2.Element, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {
2091
- tag: {
2092
- type: StringConstructor;
2093
- default: string;
2094
- };
2095
- }>> & Readonly<{}>, {
2096
- tag: string;
2097
- }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
2098
-
2099
2085
  export declare const Icon: DefineComponent<ExtractPropTypes< {
2100
2086
  type: StringConstructor;
2101
2087
  inherit: {
@@ -5001,20 +4987,6 @@ export declare const MFragment: DefineComponent< {}, () => VNode<RendererNode
5001
4987
  [key: string]: any;
5002
4988
  }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
5003
4989
 
5004
- export declare const MHTMLToImage: DefineComponent<ExtractPropTypes< {
5005
- tag: {
5006
- type: StringConstructor;
5007
- default: string;
5008
- };
5009
- }>, () => JSX_2.Element, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {
5010
- tag: {
5011
- type: StringConstructor;
5012
- default: string;
5013
- };
5014
- }>> & Readonly<{}>, {
5015
- tag: string;
5016
- }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
5017
-
5018
4990
  export declare const MIcon: DefineComponent<ExtractPropTypes< {
5019
4991
  type: StringConstructor;
5020
4992
  inherit: {
@@ -8445,6 +8417,44 @@ default: string;
8445
8417
  tag: string;
8446
8418
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
8447
8419
 
8420
+ export declare const MSnapshot: DefineComponent<ExtractPropTypes< {
8421
+ tag: {
8422
+ type: StringConstructor;
8423
+ default: string;
8424
+ };
8425
+ crossOrigin: {
8426
+ type: StringConstructor;
8427
+ default: string;
8428
+ validator: (v: any) => boolean;
8429
+ };
8430
+ transformSource: FunctionConstructor;
8431
+ options: {
8432
+ type: ObjectConstructor;
8433
+ default: () => {};
8434
+ };
8435
+ }>, () => JSX_2.Element, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, "ready"[], "ready", PublicProps, Readonly<ExtractPropTypes< {
8436
+ tag: {
8437
+ type: StringConstructor;
8438
+ default: string;
8439
+ };
8440
+ crossOrigin: {
8441
+ type: StringConstructor;
8442
+ default: string;
8443
+ validator: (v: any) => boolean;
8444
+ };
8445
+ transformSource: FunctionConstructor;
8446
+ options: {
8447
+ type: ObjectConstructor;
8448
+ default: () => {};
8449
+ };
8450
+ }>> & Readonly<{
8451
+ onReady?: ((...args: any[]) => any) | undefined;
8452
+ }>, {
8453
+ tag: string;
8454
+ options: Record<string, any>;
8455
+ crossOrigin: string;
8456
+ }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
8457
+
8448
8458
  export declare const MSortList: DefineComponent<ExtractPropTypes< {
8449
8459
  tag: {
8450
8460
  type: StringConstructor;
@@ -13288,6 +13298,44 @@ default: string;
13288
13298
  tag: string;
13289
13299
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
13290
13300
 
13301
+ export declare const Snapshot: DefineComponent<ExtractPropTypes< {
13302
+ tag: {
13303
+ type: StringConstructor;
13304
+ default: string;
13305
+ };
13306
+ crossOrigin: {
13307
+ type: StringConstructor;
13308
+ default: string;
13309
+ validator: (v: any) => boolean;
13310
+ };
13311
+ transformSource: FunctionConstructor;
13312
+ options: {
13313
+ type: ObjectConstructor;
13314
+ default: () => {};
13315
+ };
13316
+ }>, () => JSX_2.Element, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, "ready"[], "ready", PublicProps, Readonly<ExtractPropTypes< {
13317
+ tag: {
13318
+ type: StringConstructor;
13319
+ default: string;
13320
+ };
13321
+ crossOrigin: {
13322
+ type: StringConstructor;
13323
+ default: string;
13324
+ validator: (v: any) => boolean;
13325
+ };
13326
+ transformSource: FunctionConstructor;
13327
+ options: {
13328
+ type: ObjectConstructor;
13329
+ default: () => {};
13330
+ };
13331
+ }>> & Readonly<{
13332
+ onReady?: ((...args: any[]) => any) | undefined;
13333
+ }>, {
13334
+ tag: string;
13335
+ options: Record<string, any>;
13336
+ crossOrigin: string;
13337
+ }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
13338
+
13291
13339
  export declare const SortList: DefineComponent<ExtractPropTypes< {
13292
13340
  tag: {
13293
13341
  type: StringConstructor;