@progress/kendo-vue-layout 3.7.4-dev.202211100847 → 3.7.4-dev.202211301436

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