dfish-widget 1.0.40 → 1.0.42

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/lib/index.esm.js CHANGED
@@ -1465,7 +1465,11 @@ $$1.slotsChildren = function(slots, name = 'default') {
1465
1465
  const getChildren = (d) => {
1466
1466
  d && d.forEach(v => {
1467
1467
  if (typeof v.type === 'symbol') {
1468
- Array.isArray(v.children) && getChildren(v.children);
1468
+ if (Array.isArray(v.children)) {
1469
+ getChildren(v.children);
1470
+ } else if (v.type.toString() === 'Symbol(v-txt)') {
1471
+ r.push(v);
1472
+ }
1469
1473
  } else
1470
1474
  r.push(v);
1471
1475
  });
@@ -1530,7 +1534,7 @@ $$1.print = function(a, y) {
1530
1534
  if (y.input2text) {
1531
1535
  let g = $$1(this);
1532
1536
  if (g && g.isFormWidget) {
1533
- h = g.el('main').outerHTML;
1537
+ h = g.el('form').outerHTML;
1534
1538
  v = g.formText();
1535
1539
  } else
1536
1540
  v = this.value;
@@ -1557,7 +1561,7 @@ $$1.print = function(a, y) {
1557
1561
  $$1.q('input[type=hidden]', d).each(function() {
1558
1562
  var g = $$1(this);
1559
1563
  if (g && g.isFormWidget && g.$options.name != 'w-hidden') {
1560
- s = s.replace(g.el('main').outerHTML, () => '<div class="f-wdbr f-print-input-text">' + g.formText() + '</div>');
1564
+ s = s.replace(g.el('form').outerHTML, () => '<div class="f-wdbr f-print-input-text">' + g.formText() + '</div>');
1561
1565
  }
1562
1566
  });
1563
1567
  }
@@ -4419,7 +4423,7 @@ var script$_ = {
4419
4423
  this.x.loading = a;
4420
4424
  },
4421
4425
  drop() {
4422
- if (this.$slots.default) {
4426
+ if (this.hasChild) {
4423
4427
  this.showDrop = true;
4424
4428
  } else {
4425
4429
  closeMenu();
@@ -4446,7 +4450,7 @@ var script$_ = {
4446
4450
  this.drop();
4447
4451
  },
4448
4452
  html_drop() {
4449
- if (this.showDrop && this.$slots.default) {
4453
+ if (this.showDrop && this.hasChild) {
4450
4454
  let dropProps = {
4451
4455
  context: this,
4452
4456
  ownproperty: true,
@@ -4519,14 +4523,18 @@ var script$_ = {
4519
4523
  tagName() {
4520
4524
  return 'button'
4521
4525
  },
4526
+ hasChild() {
4527
+ const c = this.slots_children();
4528
+ return c && c.length
4529
+ },
4522
4530
  isCurrent() {
4523
4531
  return this.pubParent && this.pubParent.inCurrent(this)
4524
4532
  },
4525
4533
  isMore() {
4526
- return this.$slots.default && !this.getOn('click')
4534
+ return this.hasChild && !this.getOn('click')
4527
4535
  },
4528
4536
  isCombo() {
4529
- return !!(this.$slots.default && this.x.showDropIcon && this.getOn('click'))
4537
+ return !!(this.hasChild && this.x.showDropIcon && this.getOn('click'))
4530
4538
  },
4531
4539
  isDisabled() {
4532
4540
  return this.x.disabled || this.x.loading
@@ -6217,7 +6225,7 @@ var script$A = {
6217
6225
  }
6218
6226
  },
6219
6227
  snapElem() {
6220
- return this.el('main')
6228
+ return this.el('form')
6221
6229
  },
6222
6230
  hasBubble(a) {
6223
6231
  return this.snapElem().contains(a.isWidget ? a.el() : a)
@@ -6288,7 +6296,7 @@ var script$A = {
6288
6296
  html_button() {
6289
6297
  return []
6290
6298
  },
6291
- html_form() {
6299
+ html_form_slot() {
6292
6300
  return [
6293
6301
  this.slot('prepend'),
6294
6302
  this.html_input(),
@@ -6297,10 +6305,13 @@ var script$A = {
6297
6305
  ]
6298
6306
  },
6299
6307
  html_main() {
6308
+ return h('div', {class: 'w-formbase-main'}, [this.html_form(), this.slot('down')])
6309
+ },
6310
+ html_form() {
6300
6311
  let fh = this.x.inputHeight && $$1.unitSize(this.x.inputHeight);
6301
6312
  return h('div', mergeProps({
6302
- ref: 'main',
6303
- id: this.uid + 'main',
6313
+ ref: 'form',
6314
+ id: this.uid + 'form',
6304
6315
  class: ['w-input', {
6305
6316
  'w-input-border': this.hasBorder,
6306
6317
  [`f-${this.dir}-gap`]: $$1.br.compat.gap && this.x.gap,
@@ -6309,10 +6320,10 @@ var script$A = {
6309
6320
  'height': fh
6310
6321
  },
6311
6322
  title: this.input_title
6312
- }, this.main_prop), this.html_form())
6323
+ }, this.form_prop), this.html_form_slot())
6313
6324
  },
6314
6325
  html_slots() {
6315
- return [this.html_label(), this.html_main(), this.slot('after'), this.slot('dialog')]
6326
+ return [this.html_label(), this.html_main(), this.slot('right')]
6316
6327
  }
6317
6328
  },
6318
6329
  computed: {
@@ -6404,7 +6415,7 @@ var script$A = {
6404
6415
  }
6405
6416
  return s
6406
6417
  },
6407
- main_prop() {
6418
+ form_prop() {
6408
6419
  // implement
6409
6420
  },
6410
6421
  hasVal() {
@@ -6434,7 +6445,8 @@ var script$A = {
6434
6445
  'z-req': this.rules.required,
6435
6446
  'z-label-vertical': this.labelVertical,
6436
6447
  'z-fixed': !!fw,
6437
- 'z-full': this.x.inputWidth === '*'
6448
+ 'z-full': this.x.inputWidth === '*',
6449
+ 'z-slot-down': !!this.$slots.down
6438
6450
  }],
6439
6451
  style: fw && {
6440
6452
  '--w-input-width': fw
@@ -8671,7 +8683,7 @@ var script$k = {
8671
8683
  gap: 15
8672
8684
  }
8673
8685
  },
8674
- html_form() {
8686
+ html_form_slot() {
8675
8687
  return this.x.vertical ? h('div', {class: 'w-boxgroup-grid'}, this.$slots) : this.$slots
8676
8688
  },
8677
8689
  },
@@ -9270,14 +9282,24 @@ const suffixHooks = {
9270
9282
  aud: 'aif.aifc.aiff.als.awb.mp3.aac.au.wav.wma.cda.flac.m4a.mid.mka.mp2.mpc.ape.ofr.ogg.ra.wv.tta.ac3.dts.wv.shn.vqf.spc.nsf.adx.psf.minipsf.psf2.minipsf2.rsn.zst',
9271
9283
  img: 'jpg.jpeg.gif.png.bmp.tif.tiff.ico'
9272
9284
  };
9273
-
9274
- const suffix = (function() {
9275
- let r = {};
9276
- for (let k in suffixHooks) {
9277
- suffixHooks[k].split('.').forEach(v => r[v] = k == '0' ? v : k);
9278
- }
9279
- return r
9280
- })();
9285
+
9286
+ const suffix = {};
9287
+
9288
+ for (let k in suffixHooks) {
9289
+ suffixHooks[k].split('.').forEach(v => {
9290
+ suffix[v] = k == '0' ? v : k;
9291
+ });
9292
+ }
9293
+
9294
+ const fileTypesAlias = {
9295
+ video: suffixHooks.vid,
9296
+ audio: suffixHooks.aud,
9297
+ image: suffixHooks.img
9298
+ };
9299
+
9300
+ for (let k in fileTypesAlias) {
9301
+ fileTypesAlias[k] = fileTypesAlias[k].split('.').map(v => `*.${v};`).join('');
9302
+ }
9281
9303
 
9282
9304
  const getSuffix = function(url) {
9283
9305
  let a = $$1.strFrom(url || '', '.', true).toLowerCase();
@@ -9297,12 +9319,6 @@ const suffixHooks = {
9297
9319
  'T' ? 1024 * 1024 * 1024 * 1024 : 1)
9298
9320
  };
9299
9321
 
9300
- const fileTypeHooks = {
9301
- video: suffixHooks.vid,
9302
- audio: suffixHooks.aud,
9303
- image: suffixHooks.img
9304
- };
9305
-
9306
9322
  var script$g = {
9307
9323
  name: 'w-fileupload',
9308
9324
  mixins: [script$A],
@@ -9342,6 +9358,9 @@ const suffixHooks = {
9342
9358
  },
9343
9359
  getFileTypes() {
9344
9360
  let t = this.x.fileTypes;
9361
+ if (fileTypesAlias[t]) {
9362
+ t = fileTypesAlias[t];
9363
+ }
9345
9364
  return t && t !== '*.*' ? t.replace(/\*/g, '').replace(/;/g, ',').toLowerCase() : ''
9346
9365
  },
9347
9366
  getAccept() {
@@ -9350,8 +9369,7 @@ const suffixHooks = {
9350
9369
  if (!t) return
9351
9370
  let n = [];
9352
9371
  t.toLowerCase().split(',').forEach(b => {
9353
- if (!b) return
9354
- n.push(fileTypeHooks[b] || b);
9372
+ b && n.push(b);
9355
9373
  });
9356
9374
  n.forEach(b => {
9357
9375
  b && r.push(mimeType$1(b) || b);
@@ -9432,24 +9450,26 @@ const suffixHooks = {
9432
9450
  item.value = d;
9433
9451
  this.x.success && this.x.success(item.value, this, res);
9434
9452
  }
9435
- this.nextUpload();
9436
9453
  if (item.error && item.error.message) $$1.alert(item.error.message);
9437
9454
  }).catch(error => {
9438
9455
  item.error = error;
9439
9456
  item.loading = false;
9440
9457
  item.loaded = true;
9441
9458
  item.source = null;
9459
+ this.nextUpload();
9442
9460
  if (error.response && error.response.status) $$1.alert(error.response.status + ': ' + error);
9443
9461
  });
9444
9462
  } else if (!this.x.uploadSrc) {
9445
9463
  let message = '请给上传组件配置uploadSrc';
9446
9464
  item.error = {message};
9447
9465
  console.error(message);
9466
+ this.nextUpload();
9448
9467
  }
9449
9468
  },
9450
9469
  nextUpload() {
9451
9470
  for (let item of this.list) {
9452
9471
  if (item.loading) return
9472
+ if (item.error) continue
9453
9473
  if (item.file && !item.loaded) {
9454
9474
  return this.upload(item)
9455
9475
  }
@@ -9500,7 +9520,10 @@ const suffixHooks = {
9500
9520
  default: () => this.$slots.menu({item: value})
9501
9521
  }));
9502
9522
  }
9523
+ let key = value ? value.id : item.key;
9524
+ if (!key) {item.key = key = $$1.uid();}
9503
9525
  return h('div', {
9526
+ key,
9504
9527
  class: ['w-fileupload-value', {
9505
9528
  'z-loading': item.loading,
9506
9529
  'z-err': item.error
@@ -9540,18 +9563,25 @@ const suffixHooks = {
9540
9563
  ]
9541
9564
  },
9542
9565
  html_input_button() {
9543
- return h(script$J, {
9544
- ref: 'uploadbbr',
9545
- class: 'w-fileupload-bbr',
9546
- gap: 10,
9547
- }, {
9548
- default: () => [this.$slots.button ? this.$slots.button() : h(script$_, {
9549
- text: '选择文件',
9550
- icon: '.f-i .f-i-upload',
9551
- class: 'w-fileupload-button',
9552
- onclick: this.chooseFile
9553
- })]
9554
- })
9566
+ return h('div', {}, [
9567
+ h(script$J, {
9568
+ ref: 'uploadbbr',
9569
+ class: 'w-fileupload-bbr',
9570
+ gap: 10,
9571
+ }, {
9572
+ default: () => [
9573
+ this.$slots.button ? this.$slots.button({chooseFile: this.chooseFile}) :
9574
+ h(script$_, {
9575
+ text: '选择文件',
9576
+ icon: '.f-i .f-i-upload',
9577
+ class: 'w-fileupload-button',
9578
+ onclick: this.chooseFile
9579
+ }),
9580
+ this.slot('right')
9581
+ ]
9582
+ }),
9583
+ this.slot('down')
9584
+ ])
9555
9585
  },
9556
9586
  html_input_list() {
9557
9587
  return this.list.length ? h('div', {
@@ -9564,7 +9594,12 @@ const suffixHooks = {
9564
9594
  html_input() {
9565
9595
  return this.html_input_form().concat(this.canUpload && this.html_input_button(), this.html_input_list())
9566
9596
  },
9567
-
9597
+ html_main() {
9598
+ return h('div', {class: 'w-formbase-main'}, this.html_form())
9599
+ },
9600
+ html_slots() {
9601
+ return [this.html_label(), this.html_main()]
9602
+ }
9568
9603
  },
9569
9604
  computed: {
9570
9605
  validHooks() {
@@ -9818,26 +9853,34 @@ var script$e = {
9818
9853
  },
9819
9854
  html_list() {
9820
9855
  return this.list.map((item, index) => {
9821
- return h(script$f, {item, index})
9856
+ let key = item.value ? item.value.id : item.key;
9857
+ if (!key) {item.key = key = $$1.uid();}
9858
+ return h(script$f, {item, index, key})
9822
9859
  })
9823
9860
  },
9824
9861
  html_input_button() {
9825
- return h(script$J, {
9826
- ref: 'uploadbbr',
9827
- class: 'w-fileupload-bbr'
9828
- }, {
9829
- default: () => [this.$slots.button ? this.$slots.button() : h(script$_, {
9830
- ref: 'uploadbutton',
9831
- title: $$1.loc.form.choose_image,
9832
- icon: '.f-i .f-i-plus',
9833
- class: 'w-mediaupload-button',
9834
- style: {
9835
- width: $$1.unitSize(this.x.thumbnailWidth),
9836
- height: $$1.unitSize(this.x.thumbnailHeight),
9837
- },
9838
- onclick: this.chooseFile
9839
- })]
9840
- })
9862
+ return h('div', {}, [
9863
+ h(script$J, {
9864
+ ref: 'uploadbbr',
9865
+ class: 'w-fileupload-bbr'
9866
+ }, {
9867
+ default: () => [
9868
+ this.$slots.button ? this.$slots.button({chooseFile: this.chooseFile}) : h(script$_, {
9869
+ ref: 'uploadbutton',
9870
+ title: $$1.loc.form.choose_image,
9871
+ icon: '.f-i .f-i-plus',
9872
+ class: 'w-mediaupload-button',
9873
+ style: {
9874
+ width: $$1.unitSize(this.x.thumbnailWidth),
9875
+ height: $$1.unitSize(this.x.thumbnailHeight),
9876
+ },
9877
+ onclick: this.chooseFile
9878
+ }),
9879
+ this.slot('right')
9880
+ ]
9881
+ }),
9882
+ this.slot('down')
9883
+ ])
9841
9884
  },
9842
9885
  html_input() {
9843
9886
  return this.html_input_form().concat(h('div', {
@@ -10363,7 +10406,7 @@ var script$a = {
10363
10406
  onkeyup: this.onkeyup,
10364
10407
  }
10365
10408
  },
10366
- main_prop() {
10409
+ form_prop() {
10367
10410
  return {
10368
10411
  onclick: this.isNormal && this.drop
10369
10412
  }
@@ -10444,10 +10487,10 @@ var script$9 = {
10444
10487
  context: this,
10445
10488
  ownproperty: true,
10446
10489
  class: 'f-dfish-dialog w-dropbox-dialog' + (m ? ' z-mob' : ''),
10447
- width: m ? '100%' : $$1.bcr(this.el('main')).width,
10490
+ width: m ? '100%' : $$1.bcr(this.el('form')).width,
10448
10491
  autoHide: true,
10449
10492
  cover: m,
10450
- snap: m ? null : () => this.el('main'),
10493
+ snap: m ? null : () => this.el('form'),
10451
10494
  position: m ? null : 'v',
10452
10495
  indent: 1,
10453
10496
  onClose: () => this.showDrop = false
@@ -10480,7 +10523,7 @@ var script$9 = {
10480
10523
  });
10481
10524
  return r.sort().map(v => s[v].props.text).join(', ')
10482
10525
  },
10483
- main_prop() {
10526
+ form_prop() {
10484
10527
  return {
10485
10528
  onclick: this.isNormal && this.click
10486
10529
  }
@@ -10621,14 +10664,15 @@ var script$6 = {
10621
10664
  }
10622
10665
  },
10623
10666
  forms() {
10624
- return this.ownerView.fAll(null, this.el('main'))
10667
+ const to = this.$refs.to;
10668
+ return to && this.ownerView.fAll(null, to.parentNode)
10625
10669
  },
10626
10670
  snapElem() {
10627
- return this.forms()[0] || this.el('main')
10671
+ return this.forms()[0] || this.el('form')
10628
10672
  },
10629
10673
  html_form() {
10630
10674
  let c = this.slots_children();
10631
- c.splice(1, 0, h('div', {class: 'w-range-to'}, $$1.loc.to));
10675
+ c.splice(1, 0, h('div', {ref: 'to', class: 'w-range-to'}, $$1.loc.to));
10632
10676
  //c.push(h('input', {type: 'hidden', ref:'v', id: this.uid + 'hdn'}))
10633
10677
  return c
10634
10678
  },
@@ -10843,9 +10887,9 @@ var script$5 = {
10843
10887
  context: this,
10844
10888
  ownproperty: true,
10845
10889
  class: 'f-dfish-dialog',
10846
- width: $$1.bcr(this.el('main')).width,
10890
+ width: $$1.bcr(this.el('form')).width,
10847
10891
  autoHide: true,
10848
- snap:() => this.el('main'),
10892
+ snap:() => this.el('form'),
10849
10893
  position: 'v',
10850
10894
  indent: 1,
10851
10895
  onClose: () => this.showSuggest = false
@@ -10913,7 +10957,7 @@ var script$5 = {
10913
10957
  'z-clearable': this.x.clearable,
10914
10958
  }
10915
10959
  },
10916
- main_prop() {
10960
+ form_prop() {
10917
10961
  return {
10918
10962
  onclick: this.isNormal && this.onclick
10919
10963
  }
@@ -11298,10 +11342,10 @@ var script$4 = {
11298
11342
  context: this,
11299
11343
  ownproperty: true,
11300
11344
  class: 'f-dfish-dialog',
11301
- width: $$1.bcr(this.el('main')).width,
11345
+ width: $$1.bcr(this.el('form')).width,
11302
11346
  scrollY: true,
11303
11347
  autoHide: true,
11304
- snap: () => this.el('main'),
11348
+ snap: () => this.el('form'),
11305
11349
  position: 'v',
11306
11350
  indent: 1,
11307
11351
  onClose: () => this.showSuggest = false
@@ -11584,7 +11628,7 @@ const init_text = $$1.loc.form.jigsaw_drag_right;
11584
11628
  return $$1.bcr(this.$refs.thumb).width
11585
11629
  },
11586
11630
  mainWidth() {
11587
- return $$1.bcr(this.$refs.main).width
11631
+ return $$1.bcr(this.$refs.form).width
11588
11632
  },
11589
11633
  html_input() {
11590
11634
  return [
@@ -11615,7 +11659,7 @@ const init_text = $$1.loc.form.jigsaw_drag_right;
11615
11659
  })
11616
11660
  ];
11617
11661
  if (this.showDrop) {
11618
- let width = Math.max($$1.number(this.x.dropWidth), $$1.bcr(this.el('main')).width);
11662
+ let width = Math.max($$1.number(this.x.dropWidth), $$1.bcr(this.el('form')).width);
11619
11663
  let height = Math.ceil(width * (this.x.big.height / this.x.big.width));
11620
11664
  r.push(h(script$3, {
11621
11665
  ownproperty: true,
@@ -11623,7 +11667,7 @@ const init_text = $$1.loc.form.jigsaw_drag_right;
11623
11667
  height,
11624
11668
  autoHide: true,
11625
11669
  context: this,
11626
- snap: () => this.el('main'),
11670
+ snap: () => this.el('form'),
11627
11671
  position: 'v',
11628
11672
  onClose: () => this.showDrop = null
11629
11673
  }));
@@ -11647,7 +11691,7 @@ const init_text = $$1.loc.form.jigsaw_drag_right;
11647
11691
  'z-success': this.isSuccess,
11648
11692
  }
11649
11693
  },
11650
- main_prop() {
11694
+ form_prop() {
11651
11695
  return {
11652
11696
  onmouseenter: this.mouseenter
11653
11697
  }
@@ -11694,7 +11738,7 @@ var script$1 = {
11694
11738
  '--w-form-gap': $$1.unitSize(this.x.gap)
11695
11739
  }
11696
11740
  },
11697
- main_prop() {
11741
+ form_prop() {
11698
11742
  return this.name && {
11699
11743
  onclick: e => this.warn(false)
11700
11744
  }