@progress/kendo-vue-layout 3.7.2 → 3.7.3-dev.202211021441
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/cdn/js/kendo-vue-layout.js +1 -1
- package/dist/es/main.d.ts +2 -0
- package/dist/es/main.js +2 -0
- package/dist/es/package-metadata.js +1 -1
- package/dist/es/tilelayout/ResizeHandlers.d.ts +53 -0
- package/dist/es/tilelayout/ResizeHandlers.js +79 -0
- package/dist/es/tilelayout/Tile.d.ts +51 -0
- package/dist/es/tilelayout/Tile.js +353 -0
- package/dist/es/tilelayout/TileLayout.d.ts +108 -0
- package/dist/es/tilelayout/TileLayout.js +222 -0
- package/dist/es/tilelayout/interfaces/main.d.ts +135 -0
- package/dist/es/tilelayout/interfaces/main.js +1 -0
- package/dist/esm/main.d.ts +2 -0
- package/dist/esm/main.js +2 -0
- package/dist/esm/package-metadata.js +1 -1
- package/dist/esm/tilelayout/ResizeHandlers.d.ts +53 -0
- package/dist/esm/tilelayout/ResizeHandlers.js +79 -0
- package/dist/esm/tilelayout/Tile.d.ts +51 -0
- package/dist/esm/tilelayout/Tile.js +353 -0
- package/dist/esm/tilelayout/TileLayout.d.ts +108 -0
- package/dist/esm/tilelayout/TileLayout.js +222 -0
- package/dist/esm/tilelayout/interfaces/main.d.ts +135 -0
- package/dist/esm/tilelayout/interfaces/main.js +1 -0
- package/dist/npm/main.d.ts +2 -0
- package/dist/npm/main.js +2 -0
- package/dist/npm/package-metadata.js +1 -1
- package/dist/npm/tilelayout/ResizeHandlers.d.ts +53 -0
- package/dist/npm/tilelayout/ResizeHandlers.js +86 -0
- package/dist/npm/tilelayout/Tile.d.ts +51 -0
- package/dist/npm/tilelayout/Tile.js +361 -0
- package/dist/npm/tilelayout/TileLayout.d.ts +108 -0
- package/dist/npm/tilelayout/TileLayout.js +229 -0
- package/dist/npm/tilelayout/interfaces/main.d.ts +135 -0
- package/dist/npm/tilelayout/interfaces/main.js +2 -0
- package/package.json +11 -11
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = undefined && undefined.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) {
|
|
8
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
return __assign.apply(this, arguments);
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", {
|
|
16
|
+
value: true
|
|
17
|
+
});
|
|
18
|
+
exports.TileVue2 = exports.Tile = void 0;
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
var Vue = require("vue");
|
|
21
|
+
var allVue = Vue;
|
|
22
|
+
var gh = allVue.h;
|
|
23
|
+
var isV3 = allVue.version && allVue.version[0] === '3';
|
|
24
|
+
var kendo_vue_common_1 = require("@progress/kendo-vue-common");
|
|
25
|
+
var ResizeHandlers_1 = require("./ResizeHandlers");
|
|
26
|
+
/**
|
|
27
|
+
* @hidden
|
|
28
|
+
*/
|
|
29
|
+
var ANIMATION_DURATION = 200;
|
|
30
|
+
/**
|
|
31
|
+
* @hidden
|
|
32
|
+
*/
|
|
33
|
+
var TileVue2 = {
|
|
34
|
+
name: 'KendoTile',
|
|
35
|
+
props: {
|
|
36
|
+
defaultPosition: {
|
|
37
|
+
type: Object,
|
|
38
|
+
required: true
|
|
39
|
+
},
|
|
40
|
+
index: Number,
|
|
41
|
+
hintStyle: Object,
|
|
42
|
+
hintClassName: String,
|
|
43
|
+
header: [String, Function, Object],
|
|
44
|
+
body: [String, Function, Object],
|
|
45
|
+
item: [String, Function, Object],
|
|
46
|
+
resizable: {
|
|
47
|
+
type: [String, Boolean],
|
|
48
|
+
default: true,
|
|
49
|
+
validator: function validator(value) {
|
|
50
|
+
return ['horizontal', 'vertical', true, false].includes(value);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
reorderable: {
|
|
54
|
+
type: Boolean,
|
|
55
|
+
default: true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
created: function created() {
|
|
59
|
+
// state = {
|
|
60
|
+
// rtl: false
|
|
61
|
+
// };
|
|
62
|
+
// oldSize = {};
|
|
63
|
+
// draggable: { element: HTMLElement | null } | null = null;
|
|
64
|
+
// dragging = false;
|
|
65
|
+
// resizing = false;
|
|
66
|
+
// element: HTMLElement | null = null;
|
|
67
|
+
// get dragElement() {
|
|
68
|
+
// return this.draggable ? this.draggable.element : undefined;
|
|
69
|
+
// }
|
|
70
|
+
// ignoreDrag: boolean = false;
|
|
71
|
+
// pressOffset = { x: 0, y: 0 };
|
|
72
|
+
// pressXY = { x: 0, y: 0 };
|
|
73
|
+
// currentTranslate = { x: 0, y: 0 };
|
|
74
|
+
// preventDataOps: any = undefined;
|
|
75
|
+
},
|
|
76
|
+
mounted: function mounted() {
|
|
77
|
+
// if (!this.element) {
|
|
78
|
+
// return;
|
|
79
|
+
// }
|
|
80
|
+
// if (getComputedStyle(this.element).direction === 'rtl') {
|
|
81
|
+
// this.setState({
|
|
82
|
+
// rtl: true
|
|
83
|
+
// });
|
|
84
|
+
// }
|
|
85
|
+
},
|
|
86
|
+
updated: function updated() {
|
|
87
|
+
// const dragElement = this.dragElement;
|
|
88
|
+
// if (!dragElement) {
|
|
89
|
+
// return;
|
|
90
|
+
// }
|
|
91
|
+
// const newBox = dragElement.getBoundingClientRect();
|
|
92
|
+
// const oldBox = this.oldSize as any;
|
|
93
|
+
// if (this.resizing) {
|
|
94
|
+
// const diffCol = newBox.width - oldBox.width;
|
|
95
|
+
// if (this.state.rtl) {
|
|
96
|
+
// const currentM: number = parseFloat(dragElement.style.marginLeft || '0');
|
|
97
|
+
// dragElement.style.marginLeft = (currentM - diffCol) + 'px';
|
|
98
|
+
// } else {
|
|
99
|
+
// const currentM: number = parseFloat(dragElement.style.marginRight || '0');
|
|
100
|
+
// dragElement.style.marginRight = (currentM + diffCol) + 'px';
|
|
101
|
+
// }
|
|
102
|
+
// this.pressXY.x += this.state.rtl ? -diffCol : diffCol;
|
|
103
|
+
// const diffRow = newBox.height - oldBox.height;
|
|
104
|
+
// const currentBot: number = parseFloat(dragElement.style!.height!.substring(12) as any);
|
|
105
|
+
// dragElement.style.height = `calc(100% + ${(currentBot + diffRow)}px)`;
|
|
106
|
+
// this.pressXY.y += diffRow;
|
|
107
|
+
// }
|
|
108
|
+
// const deltaX = oldBox.left - newBox.left;
|
|
109
|
+
// const deltaY = oldBox.top - newBox.top;
|
|
110
|
+
// if (deltaX === 0 && deltaY === 0) {
|
|
111
|
+
// return;
|
|
112
|
+
// }
|
|
113
|
+
// if (this.dragging) {
|
|
114
|
+
// if ((prevProps.defaultPosition.order !== this.$props.defaultPosition.order ||
|
|
115
|
+
// prevProps.defaultPosition.col !== this.$props.defaultPosition.col)) {
|
|
116
|
+
// this.currentTranslate.x = 0;
|
|
117
|
+
// this.currentTranslate.y = 0;
|
|
118
|
+
// dragElement.style.transform = '';
|
|
119
|
+
// }
|
|
120
|
+
// return;
|
|
121
|
+
// }
|
|
122
|
+
// if (Math.abs(deltaY) < 15 && Math.abs(deltaX) < 15) {
|
|
123
|
+
// // improves performance and removes random flickering
|
|
124
|
+
// return;
|
|
125
|
+
// }
|
|
126
|
+
// requestAnimationFrame(() => {
|
|
127
|
+
// const domNode = this.element;
|
|
128
|
+
// if (!domNode) {
|
|
129
|
+
// return;
|
|
130
|
+
// }
|
|
131
|
+
// domNode.style.transform = `translate(${deltaX}px, ${deltaY}px)`;
|
|
132
|
+
// domNode.style.transition = 'transform 0s';
|
|
133
|
+
// requestAnimationFrame(() => {
|
|
134
|
+
// domNode.style.transform = '';
|
|
135
|
+
// domNode.style.transition = `transform ${ANIMATION_DURATION}ms cubic-bezier(0.2, 0, 0, 1) 0s`;
|
|
136
|
+
// });
|
|
137
|
+
// });
|
|
138
|
+
},
|
|
139
|
+
// @ts-ignore
|
|
140
|
+
setup: !isV3 ? undefined : function () {
|
|
141
|
+
var v3 = !!isV3;
|
|
142
|
+
return {
|
|
143
|
+
v3: v3
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
render: function render(createElement) {
|
|
147
|
+
var _this = this;
|
|
148
|
+
var h = gh || createElement;
|
|
149
|
+
var defaultSlots = (0, kendo_vue_common_1.getDefaultSlots)(this);
|
|
150
|
+
if (clearTimeout && typeof clearTimeout === 'function') {
|
|
151
|
+
clearTimeout(this.preventDataOps);
|
|
152
|
+
this.preventDataOps = window.setTimeout(function () {
|
|
153
|
+
_this.preventDataOps = undefined;
|
|
154
|
+
}, 200);
|
|
155
|
+
}
|
|
156
|
+
var position = this.$props.defaultPosition;
|
|
157
|
+
var resizable = this.$props.resizable;
|
|
158
|
+
var itemStyles = __assign({
|
|
159
|
+
gridColumnStart: position.col,
|
|
160
|
+
gridColumnEnd: "span ".concat(position.colSpan),
|
|
161
|
+
gridRowStart: position.row,
|
|
162
|
+
gridRowEnd: "span ".concat(position.rowSpan),
|
|
163
|
+
outline: 'none',
|
|
164
|
+
order: position.order
|
|
165
|
+
}, this.$props.hintStyle);
|
|
166
|
+
var card = h("div", {
|
|
167
|
+
ref: function ref(e) {
|
|
168
|
+
_this.draggable = e ? {
|
|
169
|
+
element: e
|
|
170
|
+
} : null;
|
|
171
|
+
},
|
|
172
|
+
"class": (0, kendo_vue_common_1.classNames)('k-tilelayout-item k-card', {
|
|
173
|
+
'k-cursor-grab': this.reorderable
|
|
174
|
+
}, this.$props.className),
|
|
175
|
+
style: __assign({
|
|
176
|
+
height: '100%'
|
|
177
|
+
}, this.$props.style)
|
|
178
|
+
}, [defaultSlots,
|
|
179
|
+
// @ts-ignore
|
|
180
|
+
h(ResizeHandlers_1.ResizeHandlers, {
|
|
181
|
+
onPress: this.handlePress,
|
|
182
|
+
on: this.v3 ? undefined : {
|
|
183
|
+
"press": this.handlePress,
|
|
184
|
+
"resize": this.handleResize
|
|
185
|
+
},
|
|
186
|
+
onResize: this.handleResize,
|
|
187
|
+
resizable: resizable,
|
|
188
|
+
attrs: this.v3 ? undefined : {
|
|
189
|
+
resizable: resizable,
|
|
190
|
+
rtl: this.state.rtl
|
|
191
|
+
},
|
|
192
|
+
rtl: this.state.rtl
|
|
193
|
+
})]);
|
|
194
|
+
return h("div", {
|
|
195
|
+
style: itemStyles,
|
|
196
|
+
"class": this.$props.hintClassName
|
|
197
|
+
}, [
|
|
198
|
+
// @ts-ignore function children
|
|
199
|
+
h(kendo_vue_common_1.Draggable, {
|
|
200
|
+
ref: function ref(e) {
|
|
201
|
+
_this.draggable = e;
|
|
202
|
+
},
|
|
203
|
+
onDrag: this.$props.reorderable ? this.handleDrag : undefined,
|
|
204
|
+
on: this.v3 ? undefined : {
|
|
205
|
+
"drag": this.$props.reorderable ? this.handleDrag : undefined,
|
|
206
|
+
"release": this.$props.reorderable ? this.handleRelease : undefined,
|
|
207
|
+
"press": this.$props.reorderable ? this.handlePress : undefined
|
|
208
|
+
},
|
|
209
|
+
onRelease: this.$props.reorderable ? this.handleRelease : undefined,
|
|
210
|
+
onPress: this.$props.reorderable ? this.handlePress : undefined
|
|
211
|
+
}, this.v3 ? function () {
|
|
212
|
+
return [card];
|
|
213
|
+
} : [card])]);
|
|
214
|
+
},
|
|
215
|
+
methods: {
|
|
216
|
+
handleResize: function handleResize(e, q) {
|
|
217
|
+
if (q.end) {
|
|
218
|
+
this.handleRelease();
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (!this.element) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
var x = e.clientX;
|
|
225
|
+
var y = e.clientY;
|
|
226
|
+
this.resizing = true;
|
|
227
|
+
var dX = (q.direction !== 'ns' ? x - this.pressXY.x : 0) * (this.state.rtl ? -1 : 1);
|
|
228
|
+
var dY = q.direction !== 'ew' ? y - this.pressXY.y : 0;
|
|
229
|
+
if (this.dragElement) {
|
|
230
|
+
if (this.state.rtl) {
|
|
231
|
+
this.dragElement.style.marginLeft = -dX + 'px';
|
|
232
|
+
} else {
|
|
233
|
+
this.dragElement.style.marginRight = -dX + 'px';
|
|
234
|
+
}
|
|
235
|
+
this.dragElement.style.height = "calc(100% + ".concat(dY, "px)");
|
|
236
|
+
}
|
|
237
|
+
this.element.classList.add('k-layout-item-hint', 'k-layout-item-hint-resize');
|
|
238
|
+
if (this.preventDataOps) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
var col = 0;
|
|
242
|
+
var row = 0;
|
|
243
|
+
var wrapBox = this.element.getBoundingClientRect();
|
|
244
|
+
if (dX > wrapBox.width / this.$props.defaultPosition.colSpan / 3) {
|
|
245
|
+
col = 1;
|
|
246
|
+
}
|
|
247
|
+
if (dX < -wrapBox.width / this.$props.defaultPosition.colSpan / 1.25) {
|
|
248
|
+
col = -1;
|
|
249
|
+
}
|
|
250
|
+
// vertical
|
|
251
|
+
if (dY > wrapBox.height / this.$props.defaultPosition.rowSpan / 3) {
|
|
252
|
+
row = 1;
|
|
253
|
+
}
|
|
254
|
+
if (dY < -wrapBox.height / this.$props.defaultPosition.rowSpan / 1.25) {
|
|
255
|
+
row = -1;
|
|
256
|
+
}
|
|
257
|
+
if (col !== 0 || row !== 0) {
|
|
258
|
+
this.$props.update(this.$props.index, 0, 0, row, col);
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
handlePress: function handlePress(e) {
|
|
262
|
+
if (!this.dragElement) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
this.ignoreDrag = false;
|
|
266
|
+
if (this.$props.ignoreDrag && this.$props.ignoreDrag(e.event.originalEvent)) {
|
|
267
|
+
this.ignoreDrag = true;
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (this.element) {
|
|
271
|
+
this.element.style.zIndex = '10';
|
|
272
|
+
this.element.classList.add('k-layout-item-hint');
|
|
273
|
+
}
|
|
274
|
+
this.dragElement.classList.remove('k-cursor-grab');
|
|
275
|
+
this.dragElement.classList.add('k-cursor-grabbing');
|
|
276
|
+
var rec = this.dragElement.getBoundingClientRect();
|
|
277
|
+
this.pressXY = {
|
|
278
|
+
x: e.event.clientX,
|
|
279
|
+
y: e.event.clientY
|
|
280
|
+
};
|
|
281
|
+
this.pressOffset = {
|
|
282
|
+
x: e.event.clientX - rec.x,
|
|
283
|
+
y: e.event.clientY - rec.y
|
|
284
|
+
};
|
|
285
|
+
},
|
|
286
|
+
handleDrag: function handleDrag(e) {
|
|
287
|
+
if (this.ignoreDrag) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
var dragElement = this.dragElement;
|
|
291
|
+
if (e.event.originalEvent.defaultPrevented || !dragElement) {
|
|
292
|
+
return;
|
|
293
|
+
}
|
|
294
|
+
this.dragging = true;
|
|
295
|
+
e.event.originalEvent.preventDefault();
|
|
296
|
+
var rec = dragElement.getBoundingClientRect();
|
|
297
|
+
this.currentTranslate = {
|
|
298
|
+
x: e.event.clientX - rec.x - this.pressOffset.x + this.currentTranslate.x,
|
|
299
|
+
y: e.event.clientY - rec.y - this.pressOffset.y + this.currentTranslate.y
|
|
300
|
+
};
|
|
301
|
+
dragElement.style.transform = "translate(".concat(this.currentTranslate.x, "px, ").concat(this.currentTranslate.y, "px)");
|
|
302
|
+
dragElement.style.transition = 'transform 0s';
|
|
303
|
+
if (this.preventDataOps) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
var col = 0;
|
|
307
|
+
var row = 0;
|
|
308
|
+
if (this.currentTranslate.y > 0.7 * rec.height / this.$props.defaultPosition.rowSpan) {
|
|
309
|
+
row = 1;
|
|
310
|
+
}
|
|
311
|
+
if (this.currentTranslate.y < 0.7 * -rec.height / this.$props.defaultPosition.rowSpan) {
|
|
312
|
+
row = -1;
|
|
313
|
+
}
|
|
314
|
+
if (this.currentTranslate.x > 0.7 * rec.width / this.$props.defaultPosition.colSpan) {
|
|
315
|
+
col = 1;
|
|
316
|
+
}
|
|
317
|
+
if (this.currentTranslate.x < 0.7 * -rec.width / this.$props.defaultPosition.colSpan) {
|
|
318
|
+
col = -1;
|
|
319
|
+
}
|
|
320
|
+
this.$props.update(this.$props.index, row, this.state.rtl ? -col : col, 0, 0);
|
|
321
|
+
},
|
|
322
|
+
handleRelease: function handleRelease() {
|
|
323
|
+
this.dragging = this.resizing = false;
|
|
324
|
+
this.currentTranslate = {
|
|
325
|
+
x: 0,
|
|
326
|
+
y: 0
|
|
327
|
+
};
|
|
328
|
+
if (this.element) {
|
|
329
|
+
this.element.style.zIndex = '1';
|
|
330
|
+
this.element.classList.remove('k-layout-item-hint', 'k-layout-item-hint-resize');
|
|
331
|
+
}
|
|
332
|
+
var dragElement = this.dragElement;
|
|
333
|
+
if (dragElement) {
|
|
334
|
+
dragElement.style.transform = 'translate(0px, 0px)';
|
|
335
|
+
dragElement.style.transition = "transform ".concat(ANIMATION_DURATION, "ms cubic-bezier(0.2, 0, 0, 1) 0s");
|
|
336
|
+
dragElement.style.marginRight = '0px';
|
|
337
|
+
dragElement.style.marginLeft = '0px';
|
|
338
|
+
dragElement.style.height = '100%';
|
|
339
|
+
dragElement.classList.remove('k-cursor-grabbing');
|
|
340
|
+
dragElement.classList.add('k-cursor-grab');
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
// /**
|
|
345
|
+
// * @hidden
|
|
346
|
+
// */
|
|
347
|
+
// getSnapshotBeforeUpdate(_: any) {
|
|
348
|
+
// this.oldSize = {};
|
|
349
|
+
// if (this.dragElement) {
|
|
350
|
+
// this.oldSize = this.dragElement.getBoundingClientRect();
|
|
351
|
+
// }
|
|
352
|
+
// return null;
|
|
353
|
+
// }
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
exports.TileVue2 = TileVue2;
|
|
357
|
+
/**
|
|
358
|
+
* @hidden
|
|
359
|
+
*/
|
|
360
|
+
var Tile = TileVue2;
|
|
361
|
+
exports.Tile = Tile;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
declare type DefaultData<V> = object | ((this: V) => {});
|
|
2
|
+
declare type DefaultMethods<V> = {
|
|
3
|
+
[key: string]: (this: V, ...args: any[]) => any;
|
|
4
|
+
};
|
|
5
|
+
import { DefineComponent, RecordPropsDefinition, ComponentOptions, Vue2type } from '../additionalTypes';
|
|
6
|
+
import { TileLayoutGap, TileLayoutItem, TilePosition, TileLayoutRepositionEvent, TileStrictPosition, TileLayoutAutoFlow } from './interfaces/main';
|
|
7
|
+
/**
|
|
8
|
+
* Represents the properties of [TileLayout](% slug overview_tilelayout %) component.
|
|
9
|
+
*/
|
|
10
|
+
export interface TileLayoutProps {
|
|
11
|
+
/**
|
|
12
|
+
* Sets the `id` property of the root element.
|
|
13
|
+
*/
|
|
14
|
+
id?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Represents the `dir` HTML attribute. This is used to switch from LTR to RTL.
|
|
17
|
+
*/
|
|
18
|
+
dir?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Specifies the gaps between the tiles ([see example]({% slug overview_tilelayout %}#toc-tilelayout-configuration-options)).
|
|
21
|
+
*
|
|
22
|
+
* * The possible keys are:
|
|
23
|
+
* * `rows`
|
|
24
|
+
* * `columns`
|
|
25
|
+
*/
|
|
26
|
+
gap?: TileLayoutGap;
|
|
27
|
+
/**
|
|
28
|
+
* Specifies the default number of columns ([see example]({% slug overview_tilelayout %}#toc-tilelayout-configuration-options)).
|
|
29
|
+
*/
|
|
30
|
+
columns?: number;
|
|
31
|
+
/**
|
|
32
|
+
* Specifies the default width of the columns ([see example]({% slug overview_tilelayout %}#toc-tilelayout-configuration-options)).
|
|
33
|
+
*/
|
|
34
|
+
columnWidth?: number | string;
|
|
35
|
+
/**
|
|
36
|
+
* Specifies the default height of the rows ([see example]({% slug overview_tilelayout %}#toc-tilelayout-configuration-options)).
|
|
37
|
+
*/
|
|
38
|
+
rowHeight?: number | string;
|
|
39
|
+
/**
|
|
40
|
+
* Represents the `key` field of the TileLayout item. Used for setting unique keys to the TileLayout items.
|
|
41
|
+
*/
|
|
42
|
+
dataItemKey?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The collection of items that will be rendered in the TileLayout
|
|
45
|
+
* ([see example]({% slug overview_tilelayout %}#toc-tilelayout-configuration-options)).
|
|
46
|
+
*/
|
|
47
|
+
items?: TileLayoutItem[];
|
|
48
|
+
/**
|
|
49
|
+
* The list of tiles' positions which are used when the TileLayout is in controlled mode
|
|
50
|
+
* ([see example]({% slug tiles_tilelayout %}#toc-controlling-the-position)).
|
|
51
|
+
*/
|
|
52
|
+
positions?: TilePosition[];
|
|
53
|
+
/**
|
|
54
|
+
* Fires when the user repositions the tile by either dragging or resizing
|
|
55
|
+
* ([see example]({% slug tiles_tilelayout %}#toc-controlling-the-position)).
|
|
56
|
+
*/
|
|
57
|
+
onReposition?: (event: TileLayoutRepositionEvent) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Controls how the auto-placement algorithm works, specifying exactly how auto-placed items get flowed into the TileLayout.
|
|
60
|
+
* For further reference, check [grid-auto-flow CSS](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow) article.
|
|
61
|
+
* Defaults to `column`
|
|
62
|
+
* ([see example]({% slug autoflows_tilelayout %})).
|
|
63
|
+
*/
|
|
64
|
+
autoFlow?: TileLayoutAutoFlow | String;
|
|
65
|
+
/**
|
|
66
|
+
* Use this callback to prevent or allow dragging of the tiles based on specific dom event.
|
|
67
|
+
* Setting `ignoreDrag={(e) => { return !(e.target.classList.contains("k-card-title")); }}` will make only the headers draggable.
|
|
68
|
+
* Setting `ignoreDrag={(e) => { return e.target.nodeName == "INPUT"; }}` will ignore dragging input elements.
|
|
69
|
+
*/
|
|
70
|
+
ignoreDrag?: (event: any) => boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* @hidden
|
|
74
|
+
*/
|
|
75
|
+
export interface TileLayoutState {
|
|
76
|
+
positions: TileStrictPosition[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* @hidden
|
|
80
|
+
*/
|
|
81
|
+
interface TileLayoutData {
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* @hidden
|
|
85
|
+
*/
|
|
86
|
+
export interface TileLayoutMethods {
|
|
87
|
+
[key: string]: any;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @hidden
|
|
91
|
+
*/
|
|
92
|
+
export interface TileLayoutComputed {
|
|
93
|
+
[key: string]: any;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @hidden
|
|
97
|
+
*/
|
|
98
|
+
export interface TileLayoutAll extends TileLayoutMethods, TileLayoutState, TileLayoutData, TileLayoutComputed, Vue2type {
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @hidden
|
|
102
|
+
*/
|
|
103
|
+
declare const TileLayoutVue2: ComponentOptions<Vue2type, DefaultData<TileLayoutData>, DefaultMethods<TileLayoutAll>, TileLayoutComputed, RecordPropsDefinition<TileLayoutProps>>;
|
|
104
|
+
/**
|
|
105
|
+
* @hidden
|
|
106
|
+
*/
|
|
107
|
+
declare const TileLayout: DefineComponent<TileLayoutProps, any, TileLayoutData, TileLayoutComputed, TileLayoutMethods, {}, {}, {}, string, TileLayoutProps, TileLayoutProps, {}>;
|
|
108
|
+
export { TileLayout, TileLayoutVue2 };
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __assign = undefined && undefined.__assign || function () {
|
|
4
|
+
__assign = Object.assign || function (t) {
|
|
5
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
6
|
+
s = arguments[i];
|
|
7
|
+
for (var p in s) {
|
|
8
|
+
if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
return __assign.apply(this, arguments);
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", {
|
|
16
|
+
value: true
|
|
17
|
+
});
|
|
18
|
+
exports.TileLayoutVue2 = exports.TileLayout = void 0;
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
var Vue = require("vue");
|
|
21
|
+
var allVue = Vue;
|
|
22
|
+
var gh = allVue.h;
|
|
23
|
+
var isV3 = allVue.version && allVue.version[0] === '3';
|
|
24
|
+
var kendo_vue_common_1 = require("@progress/kendo-vue-common");
|
|
25
|
+
var package_metadata_1 = require("../package-metadata");
|
|
26
|
+
var Tile_1 = require("./Tile");
|
|
27
|
+
/**
|
|
28
|
+
* @hidden
|
|
29
|
+
*/
|
|
30
|
+
var AUTO_FLOW_CLASSES = {
|
|
31
|
+
'column': 'k-grid-flow-col',
|
|
32
|
+
'row': 'k-grid-flow-row',
|
|
33
|
+
'column dense': 'k-grid-flow-col-dense',
|
|
34
|
+
'row dense': 'k-grid-flow-row-dense',
|
|
35
|
+
'unset': 'k-grid-flow-unset'
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* @hidden
|
|
39
|
+
*/
|
|
40
|
+
var TileLayoutVue2 = {
|
|
41
|
+
name: 'KendoTileLayout',
|
|
42
|
+
props: {
|
|
43
|
+
id: String,
|
|
44
|
+
dir: String,
|
|
45
|
+
gap: Object,
|
|
46
|
+
columns: Number,
|
|
47
|
+
columnWidth: [Number, String],
|
|
48
|
+
rowHeight: [Number, String],
|
|
49
|
+
dataItemKey: String,
|
|
50
|
+
items: Array,
|
|
51
|
+
positions: Array,
|
|
52
|
+
autoFlow: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: 'column',
|
|
55
|
+
validator: function validator(value) {
|
|
56
|
+
return ['column', 'row', 'column dense', 'row dense', 'unset'].includes(value);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// onReposition: PropTypes.func,
|
|
60
|
+
// ignoreDrag: PropTypes.func
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
created: function created() {
|
|
64
|
+
(0, kendo_vue_common_1.validatePackage)(package_metadata_1.packageMetadata);
|
|
65
|
+
},
|
|
66
|
+
computed: {
|
|
67
|
+
positions: function positions() {
|
|
68
|
+
return (this.$props.items || []).map(function (p, i) {
|
|
69
|
+
return Object.assign({
|
|
70
|
+
order: i,
|
|
71
|
+
rowSpan: 1,
|
|
72
|
+
colSpan: 1
|
|
73
|
+
}, p.defaultPosition);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
// /**
|
|
78
|
+
// * @hidden
|
|
79
|
+
// */
|
|
80
|
+
// static getDerivedStateFromProps(props: TileLayoutProps, state: TileLayoutState) {
|
|
81
|
+
// if (props.positions) {
|
|
82
|
+
// // The component is in controlled mode.
|
|
83
|
+
// return {
|
|
84
|
+
// positions: props.positions.map((p, i) => (Object.assign({ order: i, rowSpan: 1, colSpan: 1 }, p)))
|
|
85
|
+
// };
|
|
86
|
+
// }
|
|
87
|
+
// if (props.items && (!state.positions || (props.items.length !== state.positions.length))) {
|
|
88
|
+
// // The component is in uncontrolled mode.
|
|
89
|
+
// return {
|
|
90
|
+
// positions: props.items.map((p, i) => (Object.assign(
|
|
91
|
+
// { order: i, rowSpan: 1, colSpan: 1 }, p.defaultPosition)))
|
|
92
|
+
// };
|
|
93
|
+
// }
|
|
94
|
+
// return null;
|
|
95
|
+
// }
|
|
96
|
+
// /**
|
|
97
|
+
// * @hidden
|
|
98
|
+
// */
|
|
99
|
+
// update = (index: number, dOrder: number, dCol: number, dRowSpan = 0, dColSpan = 0) => {
|
|
100
|
+
// if (dOrder === 0 && dCol === 0 && !dColSpan && !dRowSpan) {
|
|
101
|
+
// return;
|
|
102
|
+
// }
|
|
103
|
+
// let shouldUpdate = false;
|
|
104
|
+
// const positions: Array<TileStrictPosition> = this.state.positions.map(p => Object.assign({}, p));
|
|
105
|
+
// // reordering:
|
|
106
|
+
// const current = positions[index];
|
|
107
|
+
// const other = positions.find(item => (item.order === current.order + dOrder));
|
|
108
|
+
// if (other && other !== current) {
|
|
109
|
+
// current.order += dOrder;
|
|
110
|
+
// other.order += -dOrder;
|
|
111
|
+
// shouldUpdate = true;
|
|
112
|
+
// }
|
|
113
|
+
// const proposedCol = current.col + dCol;
|
|
114
|
+
// if (dCol !== 0 && proposedCol >= 1 && proposedCol + current.colSpan <= (this.$props.columns || 3) + 1) {
|
|
115
|
+
// current.col = proposedCol;
|
|
116
|
+
// shouldUpdate = true;
|
|
117
|
+
// }
|
|
118
|
+
// // resizing:
|
|
119
|
+
// const proposedColSpan = current.colSpan + dColSpan;
|
|
120
|
+
// if (dColSpan && proposedColSpan >= 1 && proposedColSpan + current.col <= (this.$props.columns || 3) + 1) {
|
|
121
|
+
// current.colSpan = proposedColSpan;
|
|
122
|
+
// shouldUpdate = true;
|
|
123
|
+
// }
|
|
124
|
+
// const proposedRowSpan = current.rowSpan + dRowSpan;
|
|
125
|
+
// if (dRowSpan && proposedRowSpan >= 1) {
|
|
126
|
+
// current.rowSpan = proposedRowSpan;
|
|
127
|
+
// shouldUpdate = true;
|
|
128
|
+
// }
|
|
129
|
+
// if (shouldUpdate) {
|
|
130
|
+
// this.setState({ positions: positions });
|
|
131
|
+
// dispatchEvent(this.$props.onReposition, {} as any, this, { value: positions });
|
|
132
|
+
// }
|
|
133
|
+
// };
|
|
134
|
+
// @ts-ignore
|
|
135
|
+
setup: !isV3 ? undefined : function () {
|
|
136
|
+
var v3 = !!isV3;
|
|
137
|
+
return {
|
|
138
|
+
v3: v3
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
render: function render(createElement) {
|
|
142
|
+
var h = gh || createElement;
|
|
143
|
+
var _a = this.$props,
|
|
144
|
+
className = _a.className,
|
|
145
|
+
_b = _a.columns,
|
|
146
|
+
columns = _b === void 0 ? 3 : _b,
|
|
147
|
+
_c = _a.columnWidth,
|
|
148
|
+
columnWidth = _c === void 0 ? '1fr' : _c,
|
|
149
|
+
gap = _a.gap,
|
|
150
|
+
_d = _a.rowHeight,
|
|
151
|
+
rowHeight = _d === void 0 ? '1fr' : _d,
|
|
152
|
+
style = _a.style,
|
|
153
|
+
_e = _a.autoFlow,
|
|
154
|
+
autoFlow = _e === void 0 ? 'column' : _e,
|
|
155
|
+
_f = _a.items,
|
|
156
|
+
items = _f === void 0 ? [] : _f;
|
|
157
|
+
var gapValue = gap ? "".concat(typeof gap.rows === 'number' ? gap.rows + 'px' : gap.rows) + ' ' + "".concat(typeof gap.columns === 'number' ? gap.columns + 'px' : gap.columns) : 16;
|
|
158
|
+
var tileLayoutStyles = __assign({
|
|
159
|
+
gridTemplateColumns: "repeat(".concat(columns, ", minmax(0px, ").concat(typeof columnWidth === 'number' ? columnWidth + 'px' : columnWidth, "))"),
|
|
160
|
+
gridAutoRows: "minmax(0px, ".concat(typeof rowHeight === 'number' ? rowHeight + 'px' : rowHeight, ")"),
|
|
161
|
+
gap: gapValue,
|
|
162
|
+
padding: gapValue
|
|
163
|
+
}, style);
|
|
164
|
+
return h("div", {
|
|
165
|
+
dir: this.$props.dir,
|
|
166
|
+
attrs: this.v3 ? undefined : {
|
|
167
|
+
dir: this.$props.dir,
|
|
168
|
+
id: this.$props.id
|
|
169
|
+
},
|
|
170
|
+
"class": (0, kendo_vue_common_1.classNames)('k-tilelayout', AUTO_FLOW_CLASSES[autoFlow], className),
|
|
171
|
+
style: tileLayoutStyles,
|
|
172
|
+
id: this.$props.id
|
|
173
|
+
}, [items.map(function (tile, index) {
|
|
174
|
+
return (
|
|
175
|
+
// @ts-ignore function children
|
|
176
|
+
h(Tile_1.Tile, {
|
|
177
|
+
key: this.$props.dataItemKey ? (0, kendo_vue_common_1.getter)(this.$props.dataItemKey)(tile) : index,
|
|
178
|
+
update: this.update,
|
|
179
|
+
attrs: this.v3 ? undefined : {
|
|
180
|
+
update: this.update,
|
|
181
|
+
defaultPosition: this.state.positions[index],
|
|
182
|
+
index: index,
|
|
183
|
+
resizable: tile.resizable,
|
|
184
|
+
reorderable: tile.reorderable,
|
|
185
|
+
hintClassName: tile.hintClassName,
|
|
186
|
+
hintStyle: tile.hintStyle,
|
|
187
|
+
ignoreDrag: this.$props.ignoreDrag
|
|
188
|
+
},
|
|
189
|
+
defaultPosition: this.state.positions[index],
|
|
190
|
+
index: index,
|
|
191
|
+
resizable: tile.resizable,
|
|
192
|
+
reorderable: tile.reorderable,
|
|
193
|
+
style: tile.style,
|
|
194
|
+
"class": tile.className,
|
|
195
|
+
hintClassName: tile.hintClassName,
|
|
196
|
+
hintStyle: tile.hintStyle,
|
|
197
|
+
ignoreDrag: this.$props.ignoreDrag
|
|
198
|
+
}, this.v3 ? function () {
|
|
199
|
+
return [tile.item ? tile.item : [h("div", {
|
|
200
|
+
"class": "k-tilelayout-item-header k-card-header"
|
|
201
|
+
}, [tile.header ? tile.header : h("h5", {
|
|
202
|
+
"class": 'k-card-title'
|
|
203
|
+
}, [tile.header])]), h("div", {
|
|
204
|
+
"class": 'k-tilelayout-item-body k-card-body'
|
|
205
|
+
}, [tile.body])]];
|
|
206
|
+
} : [tile.item ? tile.item : [h("div", {
|
|
207
|
+
"class": "k-tilelayout-item-header k-card-header"
|
|
208
|
+
}, [tile.header ? tile.header : h("h5", {
|
|
209
|
+
"class": 'k-card-title'
|
|
210
|
+
}, [tile.header])]), h("div", {
|
|
211
|
+
"class": 'k-tilelayout-item-body k-card-body'
|
|
212
|
+
}, [tile.body])]])
|
|
213
|
+
);
|
|
214
|
+
}, this)]);
|
|
215
|
+
},
|
|
216
|
+
methods: {
|
|
217
|
+
focus: function focus() {
|
|
218
|
+
if (this.$el) {
|
|
219
|
+
this.$el.focus();
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
exports.TileLayoutVue2 = TileLayoutVue2;
|
|
225
|
+
/**
|
|
226
|
+
* @hidden
|
|
227
|
+
*/
|
|
228
|
+
var TileLayout = TileLayoutVue2;
|
|
229
|
+
exports.TileLayout = TileLayout;
|