@weitutech/by-components 1.1.153 → 1.1.155

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.
@@ -557,6 +557,24 @@ var isInContainer = exports.isInContainer = function isInContainer(el, container
557
557
  return elRect.top < containerRect.bottom && elRect.bottom > containerRect.top && elRect.right > containerRect.left && elRect.left < containerRect.right;
558
558
  };
559
559
 
560
+ /***/ }),
561
+
562
+ /***/ 175:
563
+ /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
564
+
565
+ var store = __webpack_require__(7421)('wks');
566
+ var uid = __webpack_require__(3108);
567
+ var Symbol = (__webpack_require__(6903).Symbol);
568
+ var USE_SYMBOL = typeof Symbol == 'function';
569
+
570
+ var $exports = module.exports = function (name) {
571
+ return store[name] || (store[name] =
572
+ USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
573
+ };
574
+
575
+ $exports.store = store;
576
+
577
+
560
578
  /***/ }),
561
579
 
562
580
  /***/ 261:
@@ -2706,7 +2724,7 @@ module.exports = function (it) {
2706
2724
 
2707
2725
  var def = (__webpack_require__(1672).f);
2708
2726
  var has = __webpack_require__(3066);
2709
- var TAG = __webpack_require__(5413)('toStringTag');
2727
+ var TAG = __webpack_require__(175)('toStringTag');
2710
2728
 
2711
2729
  module.exports = function (it, tag, stat) {
2712
2730
  if (it && !has(it = stat ? it : it.prototype, TAG)) def(it, TAG, { configurable: true, value: tag });
@@ -15541,7 +15559,7 @@ var setToStringTag = __webpack_require__(1123);
15541
15559
  var IteratorPrototype = {};
15542
15560
 
15543
15561
  // 25.1.2.1.1 %IteratorPrototype%[@@iterator]()
15544
- __webpack_require__(4632)(IteratorPrototype, __webpack_require__(5413)('iterator'), function () { return this; });
15562
+ __webpack_require__(4632)(IteratorPrototype, __webpack_require__(175)('iterator'), function () { return this; });
15545
15563
 
15546
15564
  module.exports = function (Constructor, NAME, next) {
15547
15565
  Constructor.prototype = create(IteratorPrototype, { next: descriptor(1, next) });
@@ -15628,7 +15646,7 @@ module.exports = function (Constructor, NAME, next) {
15628
15646
  /***/ 1275:
15629
15647
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
15630
15648
 
15631
- exports.f = __webpack_require__(5413);
15649
+ exports.f = __webpack_require__(175);
15632
15650
 
15633
15651
 
15634
15652
  /***/ }),
@@ -23927,7 +23945,7 @@ var Iterators = __webpack_require__(2833);
23927
23945
  var $iterCreate = __webpack_require__(1199);
23928
23946
  var setToStringTag = __webpack_require__(1123);
23929
23947
  var getPrototypeOf = __webpack_require__(6870);
23930
- var ITERATOR = __webpack_require__(5413)('iterator');
23948
+ var ITERATOR = __webpack_require__(175)('iterator');
23931
23949
  var BUGGY = !([].keys && 'next' in [].keys()); // Safari has buggy iterators w/o `next`
23932
23950
  var FF_ITERATOR = '@@iterator';
23933
23951
  var KEYS = 'keys';
@@ -39746,8 +39764,8 @@ var map = {
39746
39764
  "./en-gb.js": 1106,
39747
39765
  "./en-ie": 7625,
39748
39766
  "./en-ie.js": 7625,
39749
- "./en-il": 7794,
39750
- "./en-il.js": 7794,
39767
+ "./en-il": 5413,
39768
+ "./en-il.js": 5413,
39751
39769
  "./en-in": 5176,
39752
39770
  "./en-in.js": 5176,
39753
39771
  "./en-nz": 2379,
@@ -39997,20 +40015,66 @@ module.exports = function (it) {
39997
40015
  /***/ }),
39998
40016
 
39999
40017
  /***/ 5413:
40000
- /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
40001
-
40002
- var store = __webpack_require__(7421)('wks');
40003
- var uid = __webpack_require__(3108);
40004
- var Symbol = (__webpack_require__(6903).Symbol);
40005
- var USE_SYMBOL = typeof Symbol == 'function';
40018
+ /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
40006
40019
 
40007
- var $exports = module.exports = function (name) {
40008
- return store[name] || (store[name] =
40009
- USE_SYMBOL && Symbol[name] || (USE_SYMBOL ? Symbol : uid)('Symbol.' + name));
40010
- };
40020
+ //! moment.js locale configuration
40021
+ //! locale : English (Israel) [en-il]
40022
+ //! author : Chris Gedrim : https://github.com/chrisgedrim
40011
40023
 
40012
- $exports.store = store;
40024
+ ;
40025
+ (function (global, factory) {
40026
+ true ? factory(__webpack_require__(9412)) : 0;
40027
+ })(this, function (moment) {
40028
+ 'use strict';
40013
40029
 
40030
+ //! moment.js locale configuration
40031
+ var enIl = moment.defineLocale('en-il', {
40032
+ months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
40033
+ monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
40034
+ weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
40035
+ weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
40036
+ weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
40037
+ longDateFormat: {
40038
+ LT: 'HH:mm',
40039
+ LTS: 'HH:mm:ss',
40040
+ L: 'DD/MM/YYYY',
40041
+ LL: 'D MMMM YYYY',
40042
+ LLL: 'D MMMM YYYY HH:mm',
40043
+ LLLL: 'dddd, D MMMM YYYY HH:mm'
40044
+ },
40045
+ calendar: {
40046
+ sameDay: '[Today at] LT',
40047
+ nextDay: '[Tomorrow at] LT',
40048
+ nextWeek: 'dddd [at] LT',
40049
+ lastDay: '[Yesterday at] LT',
40050
+ lastWeek: '[Last] dddd [at] LT',
40051
+ sameElse: 'L'
40052
+ },
40053
+ relativeTime: {
40054
+ future: 'in %s',
40055
+ past: '%s ago',
40056
+ s: 'a few seconds',
40057
+ ss: '%d seconds',
40058
+ m: 'a minute',
40059
+ mm: '%d minutes',
40060
+ h: 'an hour',
40061
+ hh: '%d hours',
40062
+ d: 'a day',
40063
+ dd: '%d days',
40064
+ M: 'a month',
40065
+ MM: '%d months',
40066
+ y: 'a year',
40067
+ yy: '%d years'
40068
+ },
40069
+ dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
40070
+ ordinal: function (number) {
40071
+ var b = number % 10,
40072
+ output = ~~(number % 100 / 10) === 1 ? 'th' : b === 1 ? 'st' : b === 2 ? 'nd' : b === 3 ? 'rd' : 'th';
40073
+ return number + output;
40074
+ }
40075
+ });
40076
+ return enIl;
40077
+ });
40014
40078
 
40015
40079
  /***/ }),
40016
40080
 
@@ -43100,7 +43164,7 @@ __webpack_require__(5270);
43100
43164
  var global = __webpack_require__(6903);
43101
43165
  var hide = __webpack_require__(4632);
43102
43166
  var Iterators = __webpack_require__(2833);
43103
- var TO_STRING_TAG = __webpack_require__(5413)('toStringTag');
43167
+ var TO_STRING_TAG = __webpack_require__(175)('toStringTag');
43104
43168
 
43105
43169
  var DOMIterables = ('CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,' +
43106
43170
  'DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,' +
@@ -45505,70 +45569,6 @@ module.exports = Object.create || function create(O, Properties) {
45505
45569
  };
45506
45570
 
45507
45571
 
45508
- /***/ }),
45509
-
45510
- /***/ 7794:
45511
- /***/ (function(__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
45512
-
45513
- //! moment.js locale configuration
45514
- //! locale : English (Israel) [en-il]
45515
- //! author : Chris Gedrim : https://github.com/chrisgedrim
45516
-
45517
- ;
45518
- (function (global, factory) {
45519
- true ? factory(__webpack_require__(9412)) : 0;
45520
- })(this, function (moment) {
45521
- 'use strict';
45522
-
45523
- //! moment.js locale configuration
45524
- var enIl = moment.defineLocale('en-il', {
45525
- months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
45526
- monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
45527
- weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
45528
- weekdaysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
45529
- weekdaysMin: 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
45530
- longDateFormat: {
45531
- LT: 'HH:mm',
45532
- LTS: 'HH:mm:ss',
45533
- L: 'DD/MM/YYYY',
45534
- LL: 'D MMMM YYYY',
45535
- LLL: 'D MMMM YYYY HH:mm',
45536
- LLLL: 'dddd, D MMMM YYYY HH:mm'
45537
- },
45538
- calendar: {
45539
- sameDay: '[Today at] LT',
45540
- nextDay: '[Tomorrow at] LT',
45541
- nextWeek: 'dddd [at] LT',
45542
- lastDay: '[Yesterday at] LT',
45543
- lastWeek: '[Last] dddd [at] LT',
45544
- sameElse: 'L'
45545
- },
45546
- relativeTime: {
45547
- future: 'in %s',
45548
- past: '%s ago',
45549
- s: 'a few seconds',
45550
- ss: '%d seconds',
45551
- m: 'a minute',
45552
- mm: '%d minutes',
45553
- h: 'an hour',
45554
- hh: '%d hours',
45555
- d: 'a day',
45556
- dd: '%d days',
45557
- M: 'a month',
45558
- MM: '%d months',
45559
- y: 'a year',
45560
- yy: '%d years'
45561
- },
45562
- dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
45563
- ordinal: function (number) {
45564
- var b = number % 10,
45565
- output = ~~(number % 100 / 10) === 1 ? 'th' : b === 1 ? 'st' : b === 2 ? 'nd' : b === 3 ? 'rd' : 'th';
45566
- return number + output;
45567
- }
45568
- });
45569
- return enIl;
45570
- });
45571
-
45572
45572
  /***/ }),
45573
45573
 
45574
45574
  /***/ 7811:
@@ -60533,7 +60533,7 @@ var $fails = __webpack_require__(2451);
60533
60533
  var shared = __webpack_require__(7421);
60534
60534
  var setToStringTag = __webpack_require__(1123);
60535
60535
  var uid = __webpack_require__(3108);
60536
- var wks = __webpack_require__(5413);
60536
+ var wks = __webpack_require__(175);
60537
60537
  var wksExt = __webpack_require__(1275);
60538
60538
  var wksDefine = __webpack_require__(2613);
60539
60539
  var enumKeys = __webpack_require__(6358);
@@ -95201,8 +95201,8 @@ var ByPopoverSelector_component = normalizeComponent(
95201
95201
  )
95202
95202
 
95203
95203
  /* harmony default export */ var ByPopoverSelector = (ByPopoverSelector_component.exports);
95204
- ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"444f6cde-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/grid-layout/ByGridLayout.vue?vue&type=template&id=7a853977
95205
- var ByGridLayoutvue_type_template_id_7a853977_render = function render() {
95204
+ ;// ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"444f6cde-vue-loader-template"}!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/cache-loader/dist/cjs.js??ruleSet[0].use[0]!./node_modules/@vue/cli-service/node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./src/components/grid-layout/ByGridLayout.vue?vue&type=template&id=7e47dec8
95205
+ var ByGridLayoutvue_type_template_id_7e47dec8_render = function render() {
95206
95206
  var _vm = this,
95207
95207
  _c = _vm._self._c;
95208
95208
  return _c('div', {
@@ -95238,7 +95238,7 @@ var ByGridLayoutvue_type_template_id_7a853977_render = function render() {
95238
95238
  }, 'grid-item', renderItem.layoutProps, false), [_c('div', {
95239
95239
  staticClass: "by-grid-layout__item-wrapper"
95240
95240
  }, [_vm.toggleable && _vm.isEditingActive ? _c('i', {
95241
- staticClass: "by-grid-layout__delete-btn el-icon-close",
95241
+ staticClass: "by-grid-layout__delete-btn el-icon-delete",
95242
95242
  on: {
95243
95243
  "click": function ($event) {
95244
95244
  $event.stopPropagation();
@@ -95257,8 +95257,100 @@ var ByGridLayoutvue_type_template_id_7a853977_render = function render() {
95257
95257
  "layout": renderItem.layout,
95258
95258
  "index": renderItem.index
95259
95259
  })], 2)]);
95260
- }) : _vm._t("default")], 2), _vm.toggleable ? _c('div', {
95260
+ }) : _vm._t("default")], 2), _vm.hasItems && !_vm.hasRenderedItems ? _c('div', {
95261
+ staticClass: "by-grid-layout__empty-state"
95262
+ }, [_c('div', {
95263
+ staticClass: "by-grid-layout__empty-illustration"
95264
+ }, [_c('svg', {
95265
+ attrs: {
95266
+ "viewBox": "0 0 160 120",
95267
+ "xmlns": "http://www.w3.org/2000/svg"
95268
+ }
95269
+ }, [_c('defs', [_c('linearGradient', {
95270
+ attrs: {
95271
+ "id": "by-grid-layout-empty-gradient",
95272
+ "x1": "0%",
95273
+ "y1": "0%",
95274
+ "x2": "100%",
95275
+ "y2": "100%"
95276
+ }
95277
+ }, [_c('stop', {
95278
+ attrs: {
95279
+ "offset": "0%",
95280
+ "stop-color": "#e6f7ff"
95281
+ }
95282
+ }), _c('stop', {
95283
+ attrs: {
95284
+ "offset": "100%",
95285
+ "stop-color": "#f9fbff"
95286
+ }
95287
+ })], 1)], 1), _c('rect', {
95288
+ attrs: {
95289
+ "x": "12",
95290
+ "y": "24",
95291
+ "width": "136",
95292
+ "height": "72",
95293
+ "rx": "12",
95294
+ "fill": "url(#by-grid-layout-empty-gradient)"
95295
+ }
95296
+ }), _c('rect', {
95297
+ attrs: {
95298
+ "x": "32",
95299
+ "y": "42",
95300
+ "width": "32",
95301
+ "height": "22",
95302
+ "rx": "4",
95303
+ "fill": "#c6e2ff",
95304
+ "opacity": "0.6"
95305
+ }
95306
+ }), _c('rect', {
95307
+ attrs: {
95308
+ "x": "72",
95309
+ "y": "42",
95310
+ "width": "56",
95311
+ "height": "16",
95312
+ "rx": "4",
95313
+ "fill": "#d9ecff",
95314
+ "opacity": "0.8"
95315
+ }
95316
+ }), _c('rect', {
95317
+ attrs: {
95318
+ "x": "32",
95319
+ "y": "70",
95320
+ "width": "56",
95321
+ "height": "16",
95322
+ "rx": "4",
95323
+ "fill": "#d9ecff",
95324
+ "opacity": "0.8"
95325
+ }
95326
+ }), _c('rect', {
95327
+ attrs: {
95328
+ "x": "92",
95329
+ "y": "70",
95330
+ "width": "36",
95331
+ "height": "16",
95332
+ "rx": "4",
95333
+ "fill": "#ecf5ff"
95334
+ }
95335
+ }), _c('circle', {
95336
+ attrs: {
95337
+ "cx": "128",
95338
+ "cy": "34",
95339
+ "r": "6",
95340
+ "fill": "#91d5ff"
95341
+ }
95342
+ })])]), _c('div', {
95343
+ staticClass: "by-grid-layout__empty-title"
95344
+ }, [_vm._v("暂无可展示的卡片")]), _c('div', {
95345
+ staticClass: "by-grid-layout__empty-desc"
95346
+ }, [_vm._v(_vm._s(_vm.isEditing ? '点击上方添加卡片或点击右侧恢复默认布局' : '点击右侧自定义按钮进行配置'))])]) : _vm._e(), _vm.toggleable ? _c('div', {
95261
95347
  staticClass: "by-grid-layout__controls"
95348
+ }, [_c('el-tooltip', {
95349
+ attrs: {
95350
+ "content": _vm.tooltipContent,
95351
+ "placement": "left",
95352
+ "disabled": !_vm.isEditingActive || !_vm.showTooltip
95353
+ }
95262
95354
  }, [_c('div', {
95263
95355
  staticClass: "by-grid-layout__mode-toggle",
95264
95356
  class: {
@@ -95267,14 +95359,19 @@ var ByGridLayoutvue_type_template_id_7a853977_render = function render() {
95267
95359
  on: {
95268
95360
  "click": _vm.handleModeButtonClick
95269
95361
  }
95270
- }, [_c('span', [_vm._v(_vm._s(_vm.modeButtonText))])]), _vm.isEditingActive ? _c('div', {
95362
+ }, [_c('span', [_vm._v(_vm._s(_vm.modeButtonText))])])]), _vm.isEditingActive ? _c('div', {
95271
95363
  staticClass: "by-grid-layout__reset-toggle",
95272
95364
  on: {
95273
95365
  "click": _vm.handleReset
95274
95366
  }
95275
- }, [_c('span', [_vm._v("恢复默认")])]) : _vm._e()]) : _vm._e()], 1);
95367
+ }, [_c('span', [_vm._v("恢复默认")])]) : _vm._e(), _vm.isEditingActive ? _c('div', {
95368
+ staticClass: "by-grid-layout__cancel-toggle",
95369
+ on: {
95370
+ "click": _vm.handleCancel
95371
+ }
95372
+ }, [_c('span', [_vm._v("取消")])]) : _vm._e()], 1) : _vm._e()], 1);
95276
95373
  };
95277
- var ByGridLayoutvue_type_template_id_7a853977_staticRenderFns = [];
95374
+ var ByGridLayoutvue_type_template_id_7e47dec8_staticRenderFns = [];
95278
95375
 
95279
95376
  // EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.reduce.js
95280
95377
  var es_iterator_reduce = __webpack_require__(8237);
@@ -95287,6 +95384,8 @@ var vue_grid_layout_common = __webpack_require__(1176);
95287
95384
 
95288
95385
 
95289
95386
 
95387
+
95388
+
95290
95389
  const OPTIONAL_LAYOUT_KEYS = ['minH', 'maxH', 'minW', 'maxW', 'isDraggable', 'isResizable', 'static'];
95291
95390
  const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
95292
95391
 
@@ -95346,6 +95445,16 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
95346
95445
  toggleable: {
95347
95446
  type: Boolean,
95348
95447
  default: true
95448
+ },
95449
+ /** 是否显示提示 */
95450
+ showTooltip: {
95451
+ type: Boolean,
95452
+ default: true
95453
+ },
95454
+ /** 提示内容 */
95455
+ tooltipContent: {
95456
+ type: String,
95457
+ default: '编辑排版保存后生效~'
95349
95458
  }
95350
95459
  },
95351
95460
  data() {
@@ -95355,7 +95464,9 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
95355
95464
  // 防止 items.sync 与 layout-updated 相互触发造成循环
95356
95465
  isProcessingLayoutUpdate: false,
95357
95466
  isProcessingItemsSync: false,
95358
- currentMode: 'view'
95467
+ currentMode: 'view',
95468
+ // 记录每个 item 首次布局时的初始尺寸(w/h),用于恢复时还原原始大小
95469
+ initialItemMetrics: {}
95359
95470
  };
95360
95471
  },
95361
95472
  computed: {
@@ -95383,6 +95494,9 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
95383
95494
  hasItems() {
95384
95495
  return Array.isArray(this.internalItems) && this.internalItems.length > 0;
95385
95496
  },
95497
+ hasRenderedItems() {
95498
+ return this.renderItems.length > 0;
95499
+ },
95386
95500
  resolvedGridLayoutAttrs() {
95387
95501
  const attrs = {
95388
95502
  ...this.$attrs
@@ -95575,6 +95689,10 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
95575
95689
  }))
95576
95690
  });
95577
95691
  },
95692
+ handleCancel() {
95693
+ this.exitEditMode();
95694
+ this.$emit('cancel');
95695
+ },
95578
95696
  emitModeChange() {
95579
95697
  this.$emit('mode-change', this.currentMode);
95580
95698
  },
@@ -95643,6 +95761,14 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
95643
95761
  index
95644
95762
  }) => {
95645
95763
  const layoutItem = this.createLayoutItem(item, index, autoContext);
95764
+ const layoutId = layoutItem.i;
95765
+ if (layoutId && !this.initialItemMetrics[layoutId]) {
95766
+ // 仅首次记录,后续编辑(拖拽、缩放)不会覆盖原始尺寸
95767
+ this.initialItemMetrics[layoutId] = {
95768
+ w: layoutItem.w,
95769
+ h: layoutItem.h
95770
+ };
95771
+ }
95646
95772
  cloned[index] = {
95647
95773
  ...cloned[index],
95648
95774
  x: layoutItem.x,
@@ -95807,17 +95933,33 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
95807
95933
  if (!this.isEditingActive) return;
95808
95934
  // 恢复隐藏项:设置 hidden: false
95809
95935
  const id = String(hiddenItem.i);
95810
- const updatedItems = this.internalItems.map((item, index) => {
95936
+ const metrics = this.initialItemMetrics[id] || {};
95937
+ let restored = null;
95938
+ const remaining = this.internalItems.reduce((acc, item, index) => {
95811
95939
  const itemId = String(this.resolveItemId(item, index));
95812
- if (itemId !== id) return item;
95940
+ if (itemId !== id) {
95941
+ acc.push(item);
95942
+ return acc;
95943
+ }
95813
95944
  const next = {
95814
95945
  ...item,
95815
95946
  hidden: false
95816
95947
  };
95817
- if (item.originalX !== undefined) next.x = item.originalX;
95818
- if (item.originalY !== undefined) next.y = item.originalY;
95819
- return next;
95820
- });
95948
+ delete next.originalX;
95949
+ delete next.originalY;
95950
+ // 优先使用首次记录的原始尺寸;否则退回默认尺寸
95951
+ const width = metrics.w !== undefined ? metrics.w : next.w !== undefined ? next.w : this.defaultItemSize.w || 1;
95952
+ const height = metrics.h !== undefined ? metrics.h : next.h !== undefined ? next.h : this.defaultItemSize.h || 1;
95953
+ next.w = width;
95954
+ next.h = height;
95955
+ const placement = this.findRestoredPlacement(width, height);
95956
+ next.x = placement.x;
95957
+ next.y = placement.y;
95958
+ restored = next;
95959
+ return acc;
95960
+ }, []);
95961
+ if (!restored) return;
95962
+ const updatedItems = [...remaining, restored];
95821
95963
  this.commitItemsChange(updatedItems);
95822
95964
  },
95823
95965
  commitItemsChange(nextItems) {
@@ -95886,8 +96028,60 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
95886
96028
  this.setItemPropsById(id, {
95887
96029
  [key]: value
95888
96030
  });
95889
- }
96031
+ },
95890
96032
  // *************** 这里是通用方法,业务中如果要给卡片item.props填充数据,可以统一使用该方法 End ***************
96033
+
96034
+ // 寻找“最优落点”
96035
+ findRestoredPlacement(width, height) {
96036
+ var _ref3, _ref4, _attrs$colNum2;
96037
+ // 从当前布局中寻找「最后一行」优先、且尽量靠右的空位
96038
+ const layout = Array.isArray(this.internalLayout) ? this.internalLayout : [];
96039
+ const attrs = this.resolvedGridLayoutAttrs || {};
96040
+ const columnsCandidate = (_ref3 = (_ref4 = (_attrs$colNum2 = attrs.colNum) !== null && _attrs$colNum2 !== void 0 ? _attrs$colNum2 : attrs.cols) !== null && _ref4 !== void 0 ? _ref4 : attrs.col) !== null && _ref3 !== void 0 ? _ref3 : 12;
96041
+ const columns = Math.max(1, this.ensureNumber(columnsCandidate, 12));
96042
+ const normalizedW = Math.max(1, this.ensureNumber(width, this.defaultItemSize.w || 1));
96043
+ const normalizedH = Math.max(1, this.ensureNumber(height, this.defaultItemSize.h || 1));
96044
+ if (layout.length === 0) {
96045
+ return {
96046
+ x: 0,
96047
+ y: 0
96048
+ };
96049
+ }
96050
+ const maxRowY = layout.reduce((max, item) => Math.max(max, item.y), 0);
96051
+ let nextRowY = maxRowY;
96052
+ const maxIterations = 1000;
96053
+ let loops = 0;
96054
+ while (loops < maxIterations) {
96055
+ for (let x = 0; x <= columns - normalizedW; x++) {
96056
+ if (this.isAreaFree(layout, x, nextRowY, normalizedW, normalizedH)) {
96057
+ return {
96058
+ x,
96059
+ y: nextRowY
96060
+ };
96061
+ }
96062
+ }
96063
+ nextRowY += 1;
96064
+ loops++;
96065
+ }
96066
+ return {
96067
+ x: 0,
96068
+ y: nextRowY
96069
+ };
96070
+ },
96071
+ isAreaFree(layout, x, y, width, height) {
96072
+ if (!Array.isArray(layout) || layout.length === 0) return true;
96073
+ return !layout.some(item => this.doRectsOverlap({
96074
+ x,
96075
+ y,
96076
+ w: width,
96077
+ h: height
96078
+ }, item));
96079
+ },
96080
+ doRectsOverlap(a, b) {
96081
+ if (!a || !b) return false;
96082
+ const noOverlap = a.x + a.w <= b.x || b.x + b.w <= a.x || a.y + a.h <= b.y || b.y + b.h <= a.y;
96083
+ return !noOverlap;
96084
+ }
95891
96085
  }
95892
96086
  });
95893
96087
  ;// ./src/components/grid-layout/ByGridLayout.vue?vue&type=script&lang=js
@@ -95902,8 +96096,8 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
95902
96096
  ;
95903
96097
  var ByGridLayout_component = normalizeComponent(
95904
96098
  grid_layout_ByGridLayoutvue_type_script_lang_js,
95905
- ByGridLayoutvue_type_template_id_7a853977_render,
95906
- ByGridLayoutvue_type_template_id_7a853977_staticRenderFns,
96099
+ ByGridLayoutvue_type_template_id_7e47dec8_render,
96100
+ ByGridLayoutvue_type_template_id_7e47dec8_staticRenderFns,
95907
96101
  false,
95908
96102
  null,
95909
96103
  null,