@deot/vc-components 1.0.50 → 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
 
@@ -15433,6 +15515,7 @@ const Radio = /* @__PURE__ */ vue.defineComponent({
15433
15515
  checked,
15434
15516
  classes,
15435
15517
  computedLabel,
15518
+ isDisabled,
15436
15519
  handleChange,
15437
15520
  handleFocus,
15438
15521
  handleBlur
@@ -15452,7 +15535,7 @@ const Radio = /* @__PURE__ */ vue.defineComponent({
15452
15535
  }, null)]), vue.createVNode("input", {
15453
15536
  "checked": checked.value,
15454
15537
  "name": radioName.value,
15455
- "disabled": props.disabled,
15538
+ "disabled": isDisabled.value,
15456
15539
  "type": "radio",
15457
15540
  "onChange": handleChange,
15458
15541
  "onFocus": handleFocus,
@@ -15467,7 +15550,11 @@ const Radio = /* @__PURE__ */ vue.defineComponent({
15467
15550
  const COMPONENT_NAME$x = 'vc-radio-button';
15468
15551
  const RadioButton = /* @__PURE__ */ vue.defineComponent({
15469
15552
  name: COMPONENT_NAME$x,
15470
- props: props$m,
15553
+ props: {
15554
+ ...props$m,
15555
+ labelStyle: [String, Object],
15556
+ labelClass: [String, Object]
15557
+ },
15471
15558
  emits: ['update:modelValue', 'change'],
15472
15559
  setup(props, {
15473
15560
  slots
@@ -15478,6 +15565,7 @@ const RadioButton = /* @__PURE__ */ vue.defineComponent({
15478
15565
  checked,
15479
15566
  classes,
15480
15567
  computedLabel,
15568
+ isDisabled,
15481
15569
  handleChange,
15482
15570
  handleFocus,
15483
15571
  handleBlur
@@ -15489,12 +15577,15 @@ const RadioButton = /* @__PURE__ */ vue.defineComponent({
15489
15577
  }, [vue.createVNode("input", {
15490
15578
  "checked": checked.value,
15491
15579
  "name": radioName.value,
15492
- "disabled": props.disabled,
15580
+ "disabled": isDisabled.value,
15493
15581
  "type": "radio",
15494
15582
  "onChange": handleChange,
15495
15583
  "onFocus": handleFocus,
15496
15584
  "onBlur": handleBlur
15497
- }, null), slots.default ? slots.default() : computedLabel.value && vue.createVNode("span", null, [computedLabel.value])]);
15585
+ }, null), vue.createVNode("span", {
15586
+ "class": [props.labelClass, 'vc-radio-button__label'],
15587
+ "style": props.labelStyle
15588
+ }, [slots.default ? slots.default() : computedLabel.value || ''])]);
15498
15589
  };
15499
15590
  }
15500
15591
  });
@@ -15608,6 +15699,7 @@ const MRadio = /* @__PURE__ */ vue.defineComponent({
15608
15699
  checked,
15609
15700
  classes,
15610
15701
  computedLabel,
15702
+ isDisabled,
15611
15703
  handleChange,
15612
15704
  handleFocus,
15613
15705
  handleBlur
@@ -15627,7 +15719,7 @@ const MRadio = /* @__PURE__ */ vue.defineComponent({
15627
15719
  }, null)]), vue.createVNode("input", {
15628
15720
  "checked": checked.value,
15629
15721
  "name": radioName.value,
15630
- "disabled": props.disabled,
15722
+ "disabled": isDisabled.value,
15631
15723
  "type": "radio",
15632
15724
  "onChange": handleChange,
15633
15725
  "onFocus": handleFocus,
@@ -23952,7 +24044,6 @@ exports.Expand = Expand$1;
23952
24044
  exports.Form = Form;
23953
24045
  exports.FormItem = FormItem;
23954
24046
  exports.Fragment = Fragment;
23955
- exports.HTMLToImage = HTMLToImage;
23956
24047
  exports.Icon = Icon;
23957
24048
  exports.IconManager = IconManager;
23958
24049
  exports.Image = Image$1;
@@ -23997,7 +24088,6 @@ exports.MExpand = MExpand;
23997
24088
  exports.MForm = MForm;
23998
24089
  exports.MFormItem = MFormItem;
23999
24090
  exports.MFragment = MFragment;
24000
- exports.MHTMLToImage = MHTMLToImage;
24001
24091
  exports.MIcon = MIcon;
24002
24092
  exports.MImage = MImage;
24003
24093
  exports.MImageCrop = MImageCrop;
@@ -24031,6 +24121,7 @@ exports.MResizer = MResizer;
24031
24121
  exports.MScroller = MScroller;
24032
24122
  exports.MSelect = MSelect;
24033
24123
  exports.MSlider = MSlider;
24124
+ exports.MSnapshot = MSnapshot;
24034
24125
  exports.MSortList = MSortList;
24035
24126
  exports.MSpin = MSpin;
24036
24127
  exports.MSteps = MSteps;
@@ -24084,6 +24175,7 @@ exports.Scroller = Scroller;
24084
24175
  exports.ScrollerWheel = ScrollerWheel;
24085
24176
  exports.Select = Select;
24086
24177
  exports.Slider = Slider;
24178
+ exports.Snapshot = Snapshot;
24087
24179
  exports.SortList = SortList;
24088
24180
  exports.Spin = Spin;
24089
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;
@@ -12422,6 +12432,8 @@ falseValue: string | number | boolean;
12422
12432
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
12423
12433
 
12424
12434
  export declare const RadioButton: DefineComponent<ExtractPropTypes< {
12435
+ labelStyle: (ObjectConstructor | StringConstructor)[];
12436
+ labelClass: (ObjectConstructor | StringConstructor)[];
12425
12437
  disabled: {
12426
12438
  type: BooleanConstructor;
12427
12439
  default: boolean;
@@ -12450,6 +12462,8 @@ type: (StringConstructor | BooleanConstructor | NumberConstructor)[];
12450
12462
  default: boolean;
12451
12463
  };
12452
12464
  }>, () => JSX_2.Element, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("change" | "update:modelValue")[], "change" | "update:modelValue", PublicProps, Readonly<ExtractPropTypes< {
12465
+ labelStyle: (ObjectConstructor | StringConstructor)[];
12466
+ labelClass: (ObjectConstructor | StringConstructor)[];
12453
12467
  disabled: {
12454
12468
  type: BooleanConstructor;
12455
12469
  default: boolean;
@@ -13284,6 +13298,44 @@ default: string;
13284
13298
  tag: string;
13285
13299
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
13286
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
+
13287
13339
  export declare const SortList: DefineComponent<ExtractPropTypes< {
13288
13340
  tag: {
13289
13341
  type: StringConstructor;