@progress/kendo-vue-layout 3.7.4-dev.202211041243 → 3.7.4-dev.202211280833

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.
@@ -15,7 +15,7 @@ import * as Vue from 'vue';
15
15
  var allVue = Vue;
16
16
  var gh = allVue.h;
17
17
  var isV3 = allVue.version && allVue.version[0] === '3';
18
- import { classNames, Draggable, getDefaultSlots } from '@progress/kendo-vue-common';
18
+ import { canUseDOM, Draggable, getDefaultSlots } from '@progress/kendo-vue-common';
19
19
  import { ResizeHandlers } from './ResizeHandlers.js';
20
20
  /**
21
21
  * @hidden
@@ -28,12 +28,11 @@ var TileVue2 = {
28
28
  name: 'KendoTile',
29
29
  props: {
30
30
  defaultPosition: {
31
- type: Object,
32
31
  required: true
33
32
  },
34
33
  index: Number,
35
34
  hintStyle: Object,
36
- hintClassName: String,
35
+ hintClass: String,
37
36
  header: [String, Function, Object],
38
37
  body: [String, Function, Object],
39
38
  item: [String, Function, Object],
@@ -50,85 +49,115 @@ var TileVue2 = {
50
49
  }
51
50
  },
52
51
  created: function created() {
53
- // state = {
54
- // rtl: false
55
- // };
56
- // oldSize = {};
57
- // draggable: { element: HTMLElement | null } | null = null;
58
- // dragging = false;
59
- // resizing = false;
60
- // element: HTMLElement | null = null;
61
- // get dragElement() {
62
- // return this.draggable ? this.draggable.element : undefined;
63
- // }
64
- // ignoreDrag: boolean = false;
65
- // pressOffset = { x: 0, y: 0 };
66
- // pressXY = { x: 0, y: 0 };
67
- // currentTranslate = { x: 0, y: 0 };
68
- // preventDataOps: any = undefined;
52
+ this.oldSize = {};
53
+ this.dragging = false;
54
+ this.resizing = false;
55
+ this.ignoreDrag = false;
56
+ this.pressOffset = {
57
+ x: 0,
58
+ y: 0
59
+ };
60
+ this.pressXY = {
61
+ x: 0,
62
+ y: 0
63
+ };
64
+ this.currentTranslate = {
65
+ x: 0,
66
+ y: 0
67
+ };
68
+ this.prevDefaultPosition = this.$props.defaultPosition;
69
+ this.preventDataOps = undefined;
70
+ },
71
+ computed: {
72
+ wrapperClass: function wrapperClass() {
73
+ return {
74
+ 'k-tilelayout-item': true,
75
+ 'k-card': true,
76
+ 'k-cursor-grab': this.reorderable
77
+ };
78
+ }
79
+ },
80
+ data: function data() {
81
+ return {
82
+ rtl: false
83
+ };
69
84
  },
70
85
  mounted: function mounted() {
71
- // if (!this.element) {
72
- // return;
73
- // }
74
- // if (getComputedStyle(this.element).direction === 'rtl') {
75
- // this.setState({
76
- // rtl: true
77
- // });
78
- // }
86
+ if (!this.$el) {
87
+ return;
88
+ }
89
+ if (this.$el) {
90
+ this.draggable = this.$refs.draggable;
91
+ }
92
+ if (getComputedStyle(this.$el).direction === 'rtl') {
93
+ this.rtl = true;
94
+ }
95
+ },
96
+ watch: {
97
+ defaultPosition: function defaultPosition(_, oldValue) {
98
+ this.prevDefaultPosition = oldValue;
99
+ }
100
+ },
101
+ beforeUpdate: function beforeUpdate() {
102
+ this.oldSize = {};
103
+ var dragElement = this.dragElement();
104
+ if (dragElement) {
105
+ this.oldSize = dragElement.getBoundingClientRect();
106
+ }
107
+ return null;
79
108
  },
80
109
  updated: function updated() {
81
- // const dragElement = this.dragElement;
82
- // if (!dragElement) {
83
- // return;
84
- // }
85
- // const newBox = dragElement.getBoundingClientRect();
86
- // const oldBox = this.oldSize as any;
87
- // if (this.resizing) {
88
- // const diffCol = newBox.width - oldBox.width;
89
- // if (this.state.rtl) {
90
- // const currentM: number = parseFloat(dragElement.style.marginLeft || '0');
91
- // dragElement.style.marginLeft = (currentM - diffCol) + 'px';
92
- // } else {
93
- // const currentM: number = parseFloat(dragElement.style.marginRight || '0');
94
- // dragElement.style.marginRight = (currentM + diffCol) + 'px';
95
- // }
96
- // this.pressXY.x += this.state.rtl ? -diffCol : diffCol;
97
- // const diffRow = newBox.height - oldBox.height;
98
- // const currentBot: number = parseFloat(dragElement.style!.height!.substring(12) as any);
99
- // dragElement.style.height = `calc(100% + ${(currentBot + diffRow)}px)`;
100
- // this.pressXY.y += diffRow;
101
- // }
102
- // const deltaX = oldBox.left - newBox.left;
103
- // const deltaY = oldBox.top - newBox.top;
104
- // if (deltaX === 0 && deltaY === 0) {
105
- // return;
106
- // }
107
- // if (this.dragging) {
108
- // if ((prevProps.defaultPosition.order !== this.$props.defaultPosition.order ||
109
- // prevProps.defaultPosition.col !== this.$props.defaultPosition.col)) {
110
- // this.currentTranslate.x = 0;
111
- // this.currentTranslate.y = 0;
112
- // dragElement.style.transform = '';
113
- // }
114
- // return;
115
- // }
116
- // if (Math.abs(deltaY) < 15 && Math.abs(deltaX) < 15) {
117
- // // improves performance and removes random flickering
118
- // return;
119
- // }
120
- // requestAnimationFrame(() => {
121
- // const domNode = this.element;
122
- // if (!domNode) {
123
- // return;
124
- // }
125
- // domNode.style.transform = `translate(${deltaX}px, ${deltaY}px)`;
126
- // domNode.style.transition = 'transform 0s';
127
- // requestAnimationFrame(() => {
128
- // domNode.style.transform = '';
129
- // domNode.style.transition = `transform ${ANIMATION_DURATION}ms cubic-bezier(0.2, 0, 0, 1) 0s`;
130
- // });
131
- // });
110
+ var dragElement = this.dragElement();
111
+ if (!dragElement) {
112
+ return;
113
+ }
114
+ var newBox = dragElement.getBoundingClientRect();
115
+ var oldBox = this.oldSize;
116
+ var that = this;
117
+ if (this.resizing) {
118
+ var diffCol = newBox.width - oldBox.width;
119
+ if (this.rtl) {
120
+ var currentM = parseFloat(dragElement.style.marginLeft || '0');
121
+ dragElement.style.marginLeft = currentM - diffCol + 'px';
122
+ } else {
123
+ var currentM = parseFloat(dragElement.style.marginRight || '0');
124
+ dragElement.style.marginRight = currentM + diffCol + 'px';
125
+ }
126
+ this.pressXY.x += this.rtl ? -diffCol : diffCol;
127
+ var diffRow = newBox.height - oldBox.height;
128
+ var currentBot = parseFloat(dragElement.style.height.substring(12));
129
+ dragElement.style.height = "calc(100% + ".concat(currentBot + diffRow, "px)");
130
+ this.pressXY.y += diffRow;
131
+ }
132
+ var deltaX = oldBox.left - newBox.left;
133
+ var deltaY = oldBox.top - newBox.top;
134
+ if (deltaX === 0 && deltaY === 0) {
135
+ return;
136
+ }
137
+ if (this.dragging) {
138
+ if (this.prevDefaultPosition.order !== this.$props.defaultPosition.order || this.prevDefaultPosition.col !== this.$props.defaultPosition.col) {
139
+ this.currentTranslate.x = 0;
140
+ this.currentTranslate.y = 0;
141
+ dragElement.style.transform = '';
142
+ }
143
+ return;
144
+ }
145
+ if (Math.abs(deltaY) < 15 && Math.abs(deltaX) < 15) {
146
+ // improves performance and removes random flickering
147
+ return;
148
+ }
149
+ requestAnimationFrame(function () {
150
+ var domNode = that.$el;
151
+ if (!domNode) {
152
+ return;
153
+ }
154
+ domNode.style.transform = "translate(".concat(deltaX, "px, ").concat(deltaY, "px)");
155
+ domNode.style.transition = 'transform 0s';
156
+ requestAnimationFrame(function () {
157
+ domNode.style.transform = '';
158
+ domNode.style.transition = "transform ".concat(ANIMATION_DURATION, "ms cubic-bezier(0.2, 0, 0, 1) 0s");
159
+ });
160
+ });
132
161
  },
133
162
  // @ts-ignore
134
163
  setup: !isV3 ? undefined : function () {
@@ -143,9 +172,11 @@ var TileVue2 = {
143
172
  var defaultSlots = getDefaultSlots(this);
144
173
  if (clearTimeout && typeof clearTimeout === 'function') {
145
174
  clearTimeout(this.preventDataOps);
146
- this.preventDataOps = window.setTimeout(function () {
147
- _this.preventDataOps = undefined;
148
- }, 200);
175
+ if (canUseDOM) {
176
+ this.preventDataOps = window.setTimeout(function () {
177
+ _this.preventDataOps = undefined;
178
+ }, 200);
179
+ }
149
180
  }
150
181
  var position = this.$props.defaultPosition;
151
182
  var resizable = this.$props.resizable;
@@ -158,83 +189,102 @@ var TileVue2 = {
158
189
  order: position.order
159
190
  }, this.$props.hintStyle);
160
191
  var card = h("div", {
161
- ref: function ref(e) {
162
- _this.draggable = e ? {
163
- element: e
164
- } : null;
165
- },
166
- "class": classNames('k-tilelayout-item k-card', {
167
- 'k-cursor-grab': this.reorderable
168
- }, this.$props.className),
169
- style: __assign({
192
+ "class": this.wrapperClass,
193
+ style: {
170
194
  height: '100%'
171
- }, this.$props.style)
172
- }, [defaultSlots,
173
- // @ts-ignore
174
- h(ResizeHandlers, {
195
+ }
196
+ }, [defaultSlots, resizable !== 'vertical' && h(ResizeHandlers, {
197
+ onPress: this.handlePress,
198
+ on: this.v3 ? undefined : {
199
+ "press": this.handlePress,
200
+ "resize": this.handleResize
201
+ },
202
+ onResize: this.handleResize,
203
+ direction: "ew",
204
+ attrs: this.v3 ? undefined : {
205
+ direction: "ew",
206
+ rtl: this.rtl
207
+ },
208
+ rtl: this.rtl
209
+ }), resizable !== 'horizontal' && h(ResizeHandlers, {
175
210
  onPress: this.handlePress,
176
211
  on: this.v3 ? undefined : {
177
212
  "press": this.handlePress,
178
213
  "resize": this.handleResize
179
214
  },
180
215
  onResize: this.handleResize,
181
- resizable: resizable,
216
+ direction: "ns",
182
217
  attrs: this.v3 ? undefined : {
183
- resizable: resizable,
184
- rtl: this.state.rtl
218
+ direction: "ns",
219
+ rtl: this.rtl
185
220
  },
186
- rtl: this.state.rtl
221
+ rtl: this.rtl
222
+ }), resizable === true && h(ResizeHandlers, {
223
+ onPress: this.handlePress,
224
+ on: this.v3 ? undefined : {
225
+ "press": this.handlePress,
226
+ "resize": this.handleResize
227
+ },
228
+ onResize: this.handleResize,
229
+ direction: this.rtl ? 'nesw' : 'nwse',
230
+ attrs: this.v3 ? undefined : {
231
+ direction: this.rtl ? 'nesw' : 'nwse',
232
+ rtl: this.rtl
233
+ },
234
+ rtl: this.rtl
187
235
  })]);
188
236
  return h("div", {
189
237
  style: itemStyles,
190
- "class": this.$props.hintClassName
238
+ "class": this.$props.hintClass
191
239
  }, [
192
240
  // @ts-ignore function children
193
241
  h(Draggable, {
194
- ref: function ref(e) {
195
- _this.draggable = e;
196
- },
197
- onDrag: this.$props.reorderable ? this.handleDrag : undefined,
242
+ ref: 'draggable',
243
+ onDrag: this.handleDrag,
198
244
  on: this.v3 ? undefined : {
199
- "drag": this.$props.reorderable ? this.handleDrag : undefined,
200
- "release": this.$props.reorderable ? this.handleRelease : undefined,
201
- "press": this.$props.reorderable ? this.handlePress : undefined
245
+ "drag": this.handleDrag,
246
+ "release": this.handleRelease,
247
+ "press": this.handlePress
202
248
  },
203
- onRelease: this.$props.reorderable ? this.handleRelease : undefined,
204
- onPress: this.$props.reorderable ? this.handlePress : undefined
249
+ onRelease: this.handleRelease,
250
+ onPress: this.handlePress
205
251
  }, this.v3 ? function () {
206
252
  return [card];
207
253
  } : [card])]);
208
254
  },
209
255
  methods: {
256
+ dragElement: function dragElement() {
257
+ return this.draggable && this.draggable.element;
258
+ },
210
259
  handleResize: function handleResize(e, q) {
260
+ var dragElement = this.dragElement();
211
261
  if (q.end) {
212
262
  this.handleRelease();
213
263
  return;
214
264
  }
215
- if (!this.element) {
265
+ if (!this.reorderable || !this.$el) {
216
266
  return;
217
267
  }
218
268
  var x = e.clientX;
219
269
  var y = e.clientY;
220
270
  this.resizing = true;
221
- var dX = (q.direction !== 'ns' ? x - this.pressXY.x : 0) * (this.state.rtl ? -1 : 1);
271
+ var dX = (q.direction !== 'ns' ? x - this.pressXY.x : 0) * (this.rtl ? -1 : 1);
222
272
  var dY = q.direction !== 'ew' ? y - this.pressXY.y : 0;
223
- if (this.dragElement) {
224
- if (this.state.rtl) {
225
- this.dragElement.style.marginLeft = -dX + 'px';
273
+ if (dragElement) {
274
+ if (this.rtl) {
275
+ dragElement.style.marginLeft = -dX + 'px';
226
276
  } else {
227
- this.dragElement.style.marginRight = -dX + 'px';
277
+ dragElement.style.marginRight = -dX + 'px';
228
278
  }
229
- this.dragElement.style.height = "calc(100% + ".concat(dY, "px)");
279
+ dragElement.style.height = "calc(100% + ".concat(dY, "px)");
230
280
  }
231
- this.element.classList.add('k-layout-item-hint', 'k-layout-item-hint-resize');
281
+ this.$el.classList.add('k-layout-item-hint', 'k-layout-item-hint-resize');
232
282
  if (this.preventDataOps) {
233
283
  return;
234
284
  }
235
285
  var col = 0;
236
286
  var row = 0;
237
- var wrapBox = this.element.getBoundingClientRect();
287
+ var wrapBox = this.$el.getBoundingClientRect();
238
288
  if (dX > wrapBox.width / this.$props.defaultPosition.colSpan / 3) {
239
289
  col = 1;
240
290
  }
@@ -249,48 +299,49 @@ var TileVue2 = {
249
299
  row = -1;
250
300
  }
251
301
  if (col !== 0 || row !== 0) {
252
- this.$props.update(this.$props.index, 0, 0, row, col);
302
+ this.$emit('update', this.$props.index, 0, 0, row, col);
253
303
  }
254
304
  },
255
305
  handlePress: function handlePress(e) {
256
- if (!this.dragElement) {
306
+ var dragElement = this.dragElement();
307
+ if (!this.reorderable || !dragElement) {
257
308
  return;
258
309
  }
259
310
  this.ignoreDrag = false;
260
- if (this.$props.ignoreDrag && this.$props.ignoreDrag(e.event.originalEvent)) {
311
+ if (this.$props.ignoreDrag && this.$props.ignoreDrag(e.originalEvent)) {
261
312
  this.ignoreDrag = true;
262
313
  return;
263
314
  }
264
- if (this.element) {
265
- this.element.style.zIndex = '10';
266
- this.element.classList.add('k-layout-item-hint');
315
+ if (this.$el) {
316
+ this.$el.style.zIndex = '10';
317
+ this.$el.classList.add('k-layout-item-hint');
267
318
  }
268
- this.dragElement.classList.remove('k-cursor-grab');
269
- this.dragElement.classList.add('k-cursor-grabbing');
270
- var rec = this.dragElement.getBoundingClientRect();
319
+ dragElement.classList.remove('k-cursor-grab');
320
+ dragElement.classList.add('k-cursor-grabbing');
321
+ var rec = dragElement.getBoundingClientRect();
271
322
  this.pressXY = {
272
- x: e.event.clientX,
273
- y: e.event.clientY
323
+ x: e.clientX,
324
+ y: e.clientY
274
325
  };
275
326
  this.pressOffset = {
276
- x: e.event.clientX - rec.x,
277
- y: e.event.clientY - rec.y
327
+ x: e.clientX - rec.x,
328
+ y: e.clientY - rec.y
278
329
  };
279
330
  },
280
331
  handleDrag: function handleDrag(e) {
281
- if (this.ignoreDrag) {
332
+ if (!this.reorderable || this.ignoreDrag) {
282
333
  return;
283
334
  }
284
- var dragElement = this.dragElement;
285
- if (e.event.originalEvent.defaultPrevented || !dragElement) {
335
+ var dragElement = this.dragElement();
336
+ if (e.originalEvent.defaultPrevented || !dragElement) {
286
337
  return;
287
338
  }
288
339
  this.dragging = true;
289
- e.event.originalEvent.preventDefault();
340
+ e.originalEvent.preventDefault();
290
341
  var rec = dragElement.getBoundingClientRect();
291
342
  this.currentTranslate = {
292
- x: e.event.clientX - rec.x - this.pressOffset.x + this.currentTranslate.x,
293
- y: e.event.clientY - rec.y - this.pressOffset.y + this.currentTranslate.y
343
+ x: e.clientX - rec.x - this.pressOffset.x + this.currentTranslate.x,
344
+ y: e.clientY - rec.y - this.pressOffset.y + this.currentTranslate.y
294
345
  };
295
346
  dragElement.style.transform = "translate(".concat(this.currentTranslate.x, "px, ").concat(this.currentTranslate.y, "px)");
296
347
  dragElement.style.transition = 'transform 0s';
@@ -311,7 +362,7 @@ var TileVue2 = {
311
362
  if (this.currentTranslate.x < 0.7 * -rec.width / this.$props.defaultPosition.colSpan) {
312
363
  col = -1;
313
364
  }
314
- this.$props.update(this.$props.index, row, this.state.rtl ? -col : col, 0, 0);
365
+ this.$emit('update', this.$props.index, row, this.rtl ? -col : col, 0, 0);
315
366
  },
316
367
  handleRelease: function handleRelease() {
317
368
  this.dragging = this.resizing = false;
@@ -319,11 +370,11 @@ var TileVue2 = {
319
370
  x: 0,
320
371
  y: 0
321
372
  };
322
- if (this.element) {
323
- this.element.style.zIndex = '1';
324
- this.element.classList.remove('k-layout-item-hint', 'k-layout-item-hint-resize');
373
+ if (this.$el) {
374
+ this.$el.style.zIndex = '1';
375
+ this.$el.classList.remove('k-layout-item-hint', 'k-layout-item-hint-resize');
325
376
  }
326
- var dragElement = this.dragElement;
377
+ var dragElement = this.dragElement();
327
378
  if (dragElement) {
328
379
  dragElement.style.transform = 'translate(0px, 0px)';
329
380
  dragElement.style.transition = "transform ".concat(ANIMATION_DURATION, "ms cubic-bezier(0.2, 0, 0, 1) 0s");
@@ -335,16 +386,6 @@ var TileVue2 = {
335
386
  }
336
387
  }
337
388
  }
338
- // /**
339
- // * @hidden
340
- // */
341
- // getSnapshotBeforeUpdate(_: any) {
342
- // this.oldSize = {};
343
- // if (this.dragElement) {
344
- // this.oldSize = this.dragElement.getBoundingClientRect();
345
- // }
346
- // return null;
347
- // }
348
389
  };
349
390
  /**
350
391
  * @hidden