@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.
- package/lib/by-components.common.js +294 -100
- package/lib/by-components.umd.js +211 -17
- package/lib/by-components.umd.min.js +1 -1
- package/lib/index.css +1 -1
- package/package.json +1 -1
package/lib/by-components.umd.js
CHANGED
|
@@ -95211,8 +95211,8 @@ var ByPopoverSelector_component = normalizeComponent(
|
|
|
95211
95211
|
)
|
|
95212
95212
|
|
|
95213
95213
|
/* harmony default export */ var ByPopoverSelector = (ByPopoverSelector_component.exports);
|
|
95214
|
-
;// ./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-82.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=
|
|
95215
|
-
var
|
|
95214
|
+
;// ./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-82.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
|
|
95215
|
+
var ByGridLayoutvue_type_template_id_7e47dec8_render = function render() {
|
|
95216
95216
|
var _vm = this,
|
|
95217
95217
|
_c = _vm._self._c;
|
|
95218
95218
|
return _c('div', {
|
|
@@ -95248,7 +95248,7 @@ var ByGridLayoutvue_type_template_id_7a853977_render = function render() {
|
|
|
95248
95248
|
}, 'grid-item', renderItem.layoutProps, false), [_c('div', {
|
|
95249
95249
|
staticClass: "by-grid-layout__item-wrapper"
|
|
95250
95250
|
}, [_vm.toggleable && _vm.isEditingActive ? _c('i', {
|
|
95251
|
-
staticClass: "by-grid-layout__delete-btn el-icon-
|
|
95251
|
+
staticClass: "by-grid-layout__delete-btn el-icon-delete",
|
|
95252
95252
|
on: {
|
|
95253
95253
|
"click": function ($event) {
|
|
95254
95254
|
$event.stopPropagation();
|
|
@@ -95267,8 +95267,100 @@ var ByGridLayoutvue_type_template_id_7a853977_render = function render() {
|
|
|
95267
95267
|
"layout": renderItem.layout,
|
|
95268
95268
|
"index": renderItem.index
|
|
95269
95269
|
})], 2)]);
|
|
95270
|
-
}) : _vm._t("default")], 2), _vm.
|
|
95270
|
+
}) : _vm._t("default")], 2), _vm.hasItems && !_vm.hasRenderedItems ? _c('div', {
|
|
95271
|
+
staticClass: "by-grid-layout__empty-state"
|
|
95272
|
+
}, [_c('div', {
|
|
95273
|
+
staticClass: "by-grid-layout__empty-illustration"
|
|
95274
|
+
}, [_c('svg', {
|
|
95275
|
+
attrs: {
|
|
95276
|
+
"viewBox": "0 0 160 120",
|
|
95277
|
+
"xmlns": "http://www.w3.org/2000/svg"
|
|
95278
|
+
}
|
|
95279
|
+
}, [_c('defs', [_c('linearGradient', {
|
|
95280
|
+
attrs: {
|
|
95281
|
+
"id": "by-grid-layout-empty-gradient",
|
|
95282
|
+
"x1": "0%",
|
|
95283
|
+
"y1": "0%",
|
|
95284
|
+
"x2": "100%",
|
|
95285
|
+
"y2": "100%"
|
|
95286
|
+
}
|
|
95287
|
+
}, [_c('stop', {
|
|
95288
|
+
attrs: {
|
|
95289
|
+
"offset": "0%",
|
|
95290
|
+
"stop-color": "#e6f7ff"
|
|
95291
|
+
}
|
|
95292
|
+
}), _c('stop', {
|
|
95293
|
+
attrs: {
|
|
95294
|
+
"offset": "100%",
|
|
95295
|
+
"stop-color": "#f9fbff"
|
|
95296
|
+
}
|
|
95297
|
+
})], 1)], 1), _c('rect', {
|
|
95298
|
+
attrs: {
|
|
95299
|
+
"x": "12",
|
|
95300
|
+
"y": "24",
|
|
95301
|
+
"width": "136",
|
|
95302
|
+
"height": "72",
|
|
95303
|
+
"rx": "12",
|
|
95304
|
+
"fill": "url(#by-grid-layout-empty-gradient)"
|
|
95305
|
+
}
|
|
95306
|
+
}), _c('rect', {
|
|
95307
|
+
attrs: {
|
|
95308
|
+
"x": "32",
|
|
95309
|
+
"y": "42",
|
|
95310
|
+
"width": "32",
|
|
95311
|
+
"height": "22",
|
|
95312
|
+
"rx": "4",
|
|
95313
|
+
"fill": "#c6e2ff",
|
|
95314
|
+
"opacity": "0.6"
|
|
95315
|
+
}
|
|
95316
|
+
}), _c('rect', {
|
|
95317
|
+
attrs: {
|
|
95318
|
+
"x": "72",
|
|
95319
|
+
"y": "42",
|
|
95320
|
+
"width": "56",
|
|
95321
|
+
"height": "16",
|
|
95322
|
+
"rx": "4",
|
|
95323
|
+
"fill": "#d9ecff",
|
|
95324
|
+
"opacity": "0.8"
|
|
95325
|
+
}
|
|
95326
|
+
}), _c('rect', {
|
|
95327
|
+
attrs: {
|
|
95328
|
+
"x": "32",
|
|
95329
|
+
"y": "70",
|
|
95330
|
+
"width": "56",
|
|
95331
|
+
"height": "16",
|
|
95332
|
+
"rx": "4",
|
|
95333
|
+
"fill": "#d9ecff",
|
|
95334
|
+
"opacity": "0.8"
|
|
95335
|
+
}
|
|
95336
|
+
}), _c('rect', {
|
|
95337
|
+
attrs: {
|
|
95338
|
+
"x": "92",
|
|
95339
|
+
"y": "70",
|
|
95340
|
+
"width": "36",
|
|
95341
|
+
"height": "16",
|
|
95342
|
+
"rx": "4",
|
|
95343
|
+
"fill": "#ecf5ff"
|
|
95344
|
+
}
|
|
95345
|
+
}), _c('circle', {
|
|
95346
|
+
attrs: {
|
|
95347
|
+
"cx": "128",
|
|
95348
|
+
"cy": "34",
|
|
95349
|
+
"r": "6",
|
|
95350
|
+
"fill": "#91d5ff"
|
|
95351
|
+
}
|
|
95352
|
+
})])]), _c('div', {
|
|
95353
|
+
staticClass: "by-grid-layout__empty-title"
|
|
95354
|
+
}, [_vm._v("暂无可展示的卡片")]), _c('div', {
|
|
95355
|
+
staticClass: "by-grid-layout__empty-desc"
|
|
95356
|
+
}, [_vm._v(_vm._s(_vm.isEditing ? '点击上方添加卡片或点击右侧恢复默认布局' : '点击右侧自定义按钮进行配置'))])]) : _vm._e(), _vm.toggleable ? _c('div', {
|
|
95271
95357
|
staticClass: "by-grid-layout__controls"
|
|
95358
|
+
}, [_c('el-tooltip', {
|
|
95359
|
+
attrs: {
|
|
95360
|
+
"content": _vm.tooltipContent,
|
|
95361
|
+
"placement": "left",
|
|
95362
|
+
"disabled": !_vm.isEditingActive || !_vm.showTooltip
|
|
95363
|
+
}
|
|
95272
95364
|
}, [_c('div', {
|
|
95273
95365
|
staticClass: "by-grid-layout__mode-toggle",
|
|
95274
95366
|
class: {
|
|
@@ -95277,14 +95369,19 @@ var ByGridLayoutvue_type_template_id_7a853977_render = function render() {
|
|
|
95277
95369
|
on: {
|
|
95278
95370
|
"click": _vm.handleModeButtonClick
|
|
95279
95371
|
}
|
|
95280
|
-
}, [_c('span', [_vm._v(_vm._s(_vm.modeButtonText))])]), _vm.isEditingActive ? _c('div', {
|
|
95372
|
+
}, [_c('span', [_vm._v(_vm._s(_vm.modeButtonText))])])]), _vm.isEditingActive ? _c('div', {
|
|
95281
95373
|
staticClass: "by-grid-layout__reset-toggle",
|
|
95282
95374
|
on: {
|
|
95283
95375
|
"click": _vm.handleReset
|
|
95284
95376
|
}
|
|
95285
|
-
}, [_c('span', [_vm._v("恢复默认")])]) : _vm._e()
|
|
95377
|
+
}, [_c('span', [_vm._v("恢复默认")])]) : _vm._e(), _vm.isEditingActive ? _c('div', {
|
|
95378
|
+
staticClass: "by-grid-layout__cancel-toggle",
|
|
95379
|
+
on: {
|
|
95380
|
+
"click": _vm.handleCancel
|
|
95381
|
+
}
|
|
95382
|
+
}, [_c('span', [_vm._v("取消")])]) : _vm._e()], 1) : _vm._e()], 1);
|
|
95286
95383
|
};
|
|
95287
|
-
var
|
|
95384
|
+
var ByGridLayoutvue_type_template_id_7e47dec8_staticRenderFns = [];
|
|
95288
95385
|
|
|
95289
95386
|
// EXTERNAL MODULE: ./node_modules/core-js/modules/es.iterator.reduce.js
|
|
95290
95387
|
var es_iterator_reduce = __webpack_require__(8237);
|
|
@@ -95297,6 +95394,8 @@ var vue_grid_layout_common = __webpack_require__(2498);
|
|
|
95297
95394
|
|
|
95298
95395
|
|
|
95299
95396
|
|
|
95397
|
+
|
|
95398
|
+
|
|
95300
95399
|
const OPTIONAL_LAYOUT_KEYS = ['minH', 'maxH', 'minW', 'maxW', 'isDraggable', 'isResizable', 'static'];
|
|
95301
95400
|
const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
|
|
95302
95401
|
|
|
@@ -95356,6 +95455,16 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
|
|
|
95356
95455
|
toggleable: {
|
|
95357
95456
|
type: Boolean,
|
|
95358
95457
|
default: true
|
|
95458
|
+
},
|
|
95459
|
+
/** 是否显示提示 */
|
|
95460
|
+
showTooltip: {
|
|
95461
|
+
type: Boolean,
|
|
95462
|
+
default: true
|
|
95463
|
+
},
|
|
95464
|
+
/** 提示内容 */
|
|
95465
|
+
tooltipContent: {
|
|
95466
|
+
type: String,
|
|
95467
|
+
default: '编辑排版保存后生效~'
|
|
95359
95468
|
}
|
|
95360
95469
|
},
|
|
95361
95470
|
data() {
|
|
@@ -95365,7 +95474,9 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
|
|
|
95365
95474
|
// 防止 items.sync 与 layout-updated 相互触发造成循环
|
|
95366
95475
|
isProcessingLayoutUpdate: false,
|
|
95367
95476
|
isProcessingItemsSync: false,
|
|
95368
|
-
currentMode: 'view'
|
|
95477
|
+
currentMode: 'view',
|
|
95478
|
+
// 记录每个 item 首次布局时的初始尺寸(w/h),用于恢复时还原原始大小
|
|
95479
|
+
initialItemMetrics: {}
|
|
95369
95480
|
};
|
|
95370
95481
|
},
|
|
95371
95482
|
computed: {
|
|
@@ -95393,6 +95504,9 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
|
|
|
95393
95504
|
hasItems() {
|
|
95394
95505
|
return Array.isArray(this.internalItems) && this.internalItems.length > 0;
|
|
95395
95506
|
},
|
|
95507
|
+
hasRenderedItems() {
|
|
95508
|
+
return this.renderItems.length > 0;
|
|
95509
|
+
},
|
|
95396
95510
|
resolvedGridLayoutAttrs() {
|
|
95397
95511
|
const attrs = {
|
|
95398
95512
|
...this.$attrs
|
|
@@ -95585,6 +95699,10 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
|
|
|
95585
95699
|
}))
|
|
95586
95700
|
});
|
|
95587
95701
|
},
|
|
95702
|
+
handleCancel() {
|
|
95703
|
+
this.exitEditMode();
|
|
95704
|
+
this.$emit('cancel');
|
|
95705
|
+
},
|
|
95588
95706
|
emitModeChange() {
|
|
95589
95707
|
this.$emit('mode-change', this.currentMode);
|
|
95590
95708
|
},
|
|
@@ -95653,6 +95771,14 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
|
|
|
95653
95771
|
index
|
|
95654
95772
|
}) => {
|
|
95655
95773
|
const layoutItem = this.createLayoutItem(item, index, autoContext);
|
|
95774
|
+
const layoutId = layoutItem.i;
|
|
95775
|
+
if (layoutId && !this.initialItemMetrics[layoutId]) {
|
|
95776
|
+
// 仅首次记录,后续编辑(拖拽、缩放)不会覆盖原始尺寸
|
|
95777
|
+
this.initialItemMetrics[layoutId] = {
|
|
95778
|
+
w: layoutItem.w,
|
|
95779
|
+
h: layoutItem.h
|
|
95780
|
+
};
|
|
95781
|
+
}
|
|
95656
95782
|
cloned[index] = {
|
|
95657
95783
|
...cloned[index],
|
|
95658
95784
|
x: layoutItem.x,
|
|
@@ -95817,17 +95943,33 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
|
|
|
95817
95943
|
if (!this.isEditingActive) return;
|
|
95818
95944
|
// 恢复隐藏项:设置 hidden: false
|
|
95819
95945
|
const id = String(hiddenItem.i);
|
|
95820
|
-
const
|
|
95946
|
+
const metrics = this.initialItemMetrics[id] || {};
|
|
95947
|
+
let restored = null;
|
|
95948
|
+
const remaining = this.internalItems.reduce((acc, item, index) => {
|
|
95821
95949
|
const itemId = String(this.resolveItemId(item, index));
|
|
95822
|
-
if (itemId !== id)
|
|
95950
|
+
if (itemId !== id) {
|
|
95951
|
+
acc.push(item);
|
|
95952
|
+
return acc;
|
|
95953
|
+
}
|
|
95823
95954
|
const next = {
|
|
95824
95955
|
...item,
|
|
95825
95956
|
hidden: false
|
|
95826
95957
|
};
|
|
95827
|
-
|
|
95828
|
-
|
|
95829
|
-
|
|
95830
|
-
|
|
95958
|
+
delete next.originalX;
|
|
95959
|
+
delete next.originalY;
|
|
95960
|
+
// 优先使用首次记录的原始尺寸;否则退回默认尺寸
|
|
95961
|
+
const width = metrics.w !== undefined ? metrics.w : next.w !== undefined ? next.w : this.defaultItemSize.w || 1;
|
|
95962
|
+
const height = metrics.h !== undefined ? metrics.h : next.h !== undefined ? next.h : this.defaultItemSize.h || 1;
|
|
95963
|
+
next.w = width;
|
|
95964
|
+
next.h = height;
|
|
95965
|
+
const placement = this.findRestoredPlacement(width, height);
|
|
95966
|
+
next.x = placement.x;
|
|
95967
|
+
next.y = placement.y;
|
|
95968
|
+
restored = next;
|
|
95969
|
+
return acc;
|
|
95970
|
+
}, []);
|
|
95971
|
+
if (!restored) return;
|
|
95972
|
+
const updatedItems = [...remaining, restored];
|
|
95831
95973
|
this.commitItemsChange(updatedItems);
|
|
95832
95974
|
},
|
|
95833
95975
|
commitItemsChange(nextItems) {
|
|
@@ -95896,8 +96038,60 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
|
|
|
95896
96038
|
this.setItemPropsById(id, {
|
|
95897
96039
|
[key]: value
|
|
95898
96040
|
});
|
|
95899
|
-
}
|
|
96041
|
+
},
|
|
95900
96042
|
// *************** 这里是通用方法,业务中如果要给卡片item.props填充数据,可以统一使用该方法 End ***************
|
|
96043
|
+
|
|
96044
|
+
// 寻找“最优落点”
|
|
96045
|
+
findRestoredPlacement(width, height) {
|
|
96046
|
+
var _ref3, _ref4, _attrs$colNum2;
|
|
96047
|
+
// 从当前布局中寻找「最后一行」优先、且尽量靠右的空位
|
|
96048
|
+
const layout = Array.isArray(this.internalLayout) ? this.internalLayout : [];
|
|
96049
|
+
const attrs = this.resolvedGridLayoutAttrs || {};
|
|
96050
|
+
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;
|
|
96051
|
+
const columns = Math.max(1, this.ensureNumber(columnsCandidate, 12));
|
|
96052
|
+
const normalizedW = Math.max(1, this.ensureNumber(width, this.defaultItemSize.w || 1));
|
|
96053
|
+
const normalizedH = Math.max(1, this.ensureNumber(height, this.defaultItemSize.h || 1));
|
|
96054
|
+
if (layout.length === 0) {
|
|
96055
|
+
return {
|
|
96056
|
+
x: 0,
|
|
96057
|
+
y: 0
|
|
96058
|
+
};
|
|
96059
|
+
}
|
|
96060
|
+
const maxRowY = layout.reduce((max, item) => Math.max(max, item.y), 0);
|
|
96061
|
+
let nextRowY = maxRowY;
|
|
96062
|
+
const maxIterations = 1000;
|
|
96063
|
+
let loops = 0;
|
|
96064
|
+
while (loops < maxIterations) {
|
|
96065
|
+
for (let x = 0; x <= columns - normalizedW; x++) {
|
|
96066
|
+
if (this.isAreaFree(layout, x, nextRowY, normalizedW, normalizedH)) {
|
|
96067
|
+
return {
|
|
96068
|
+
x,
|
|
96069
|
+
y: nextRowY
|
|
96070
|
+
};
|
|
96071
|
+
}
|
|
96072
|
+
}
|
|
96073
|
+
nextRowY += 1;
|
|
96074
|
+
loops++;
|
|
96075
|
+
}
|
|
96076
|
+
return {
|
|
96077
|
+
x: 0,
|
|
96078
|
+
y: nextRowY
|
|
96079
|
+
};
|
|
96080
|
+
},
|
|
96081
|
+
isAreaFree(layout, x, y, width, height) {
|
|
96082
|
+
if (!Array.isArray(layout) || layout.length === 0) return true;
|
|
96083
|
+
return !layout.some(item => this.doRectsOverlap({
|
|
96084
|
+
x,
|
|
96085
|
+
y,
|
|
96086
|
+
w: width,
|
|
96087
|
+
h: height
|
|
96088
|
+
}, item));
|
|
96089
|
+
},
|
|
96090
|
+
doRectsOverlap(a, b) {
|
|
96091
|
+
if (!a || !b) return false;
|
|
96092
|
+
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;
|
|
96093
|
+
return !noOverlap;
|
|
96094
|
+
}
|
|
95901
96095
|
}
|
|
95902
96096
|
});
|
|
95903
96097
|
;// ./src/components/grid-layout/ByGridLayout.vue?vue&type=script&lang=js
|
|
@@ -95912,8 +96106,8 @@ const GRID_ITEM_KEYS = ['x', 'y', 'w', 'h', 'i', ...OPTIONAL_LAYOUT_KEYS];
|
|
|
95912
96106
|
;
|
|
95913
96107
|
var ByGridLayout_component = normalizeComponent(
|
|
95914
96108
|
grid_layout_ByGridLayoutvue_type_script_lang_js,
|
|
95915
|
-
|
|
95916
|
-
|
|
96109
|
+
ByGridLayoutvue_type_template_id_7e47dec8_render,
|
|
96110
|
+
ByGridLayoutvue_type_template_id_7e47dec8_staticRenderFns,
|
|
95917
96111
|
false,
|
|
95918
96112
|
null,
|
|
95919
96113
|
null,
|