@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.
@@ -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 () {
@@ -149,9 +178,11 @@ var TileVue2 = {
149
178
  var defaultSlots = (0, kendo_vue_common_1.getDefaultSlots)(this);
150
179
  if (clearTimeout && typeof clearTimeout === 'function') {
151
180
  clearTimeout(this.preventDataOps);
152
- this.preventDataOps = window.setTimeout(function () {
153
- _this.preventDataOps = undefined;
154
- }, 200);
181
+ if (kendo_vue_common_1.canUseDOM) {
182
+ this.preventDataOps = window.setTimeout(function () {
183
+ _this.preventDataOps = undefined;
184
+ }, 200);
185
+ }
155
186
  }
156
187
  var position = this.$props.defaultPosition;
157
188
  var resizable = this.$props.resizable;
@@ -164,83 +195,102 @@ var TileVue2 = {
164
195
  order: position.order
165
196
  }, this.$props.hintStyle);
166
197
  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({
198
+ "class": this.wrapperClass,
199
+ style: {
176
200
  height: '100%'
177
- }, this.$props.style)
178
- }, [defaultSlots,
179
- // @ts-ignore
180
- h(ResizeHandlers_1.ResizeHandlers, {
201
+ }
202
+ }, [defaultSlots, resizable !== 'vertical' && h(ResizeHandlers_1.ResizeHandlers, {
181
203
  onPress: this.handlePress,
182
204
  on: this.v3 ? undefined : {
183
205
  "press": this.handlePress,
184
206
  "resize": this.handleResize
185
207
  },
186
208
  onResize: this.handleResize,
187
- resizable: resizable,
209
+ direction: "ew",
188
210
  attrs: this.v3 ? undefined : {
189
- resizable: resizable,
190
- rtl: this.state.rtl
211
+ direction: "ew",
212
+ rtl: this.rtl
191
213
  },
192
- 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
193
241
  })]);
194
242
  return h("div", {
195
243
  style: itemStyles,
196
- "class": this.$props.hintClassName
244
+ "class": this.$props.hintClass
197
245
  }, [
198
246
  // @ts-ignore function children
199
247
  h(kendo_vue_common_1.Draggable, {
200
- ref: function ref(e) {
201
- _this.draggable = e;
202
- },
203
- onDrag: this.$props.reorderable ? this.handleDrag : undefined,
248
+ ref: 'draggable',
249
+ onDrag: this.handleDrag,
204
250
  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
251
+ "drag": this.handleDrag,
252
+ "release": this.handleRelease,
253
+ "press": this.handlePress
208
254
  },
209
- onRelease: this.$props.reorderable ? this.handleRelease : undefined,
210
- onPress: this.$props.reorderable ? this.handlePress : undefined
255
+ onRelease: this.handleRelease,
256
+ onPress: this.handlePress
211
257
  }, this.v3 ? function () {
212
258
  return [card];
213
259
  } : [card])]);
214
260
  },
215
261
  methods: {
262
+ dragElement: function dragElement() {
263
+ return this.draggable && this.draggable.element;
264
+ },
216
265
  handleResize: function handleResize(e, q) {
266
+ var dragElement = this.dragElement();
217
267
  if (q.end) {
218
268
  this.handleRelease();
219
269
  return;
220
270
  }
221
- if (!this.element) {
271
+ if (!this.reorderable || !this.$el) {
222
272
  return;
223
273
  }
224
274
  var x = e.clientX;
225
275
  var y = e.clientY;
226
276
  this.resizing = true;
227
- 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);
228
278
  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';
279
+ if (dragElement) {
280
+ if (this.rtl) {
281
+ dragElement.style.marginLeft = -dX + 'px';
232
282
  } else {
233
- this.dragElement.style.marginRight = -dX + 'px';
283
+ dragElement.style.marginRight = -dX + 'px';
234
284
  }
235
- this.dragElement.style.height = "calc(100% + ".concat(dY, "px)");
285
+ dragElement.style.height = "calc(100% + ".concat(dY, "px)");
236
286
  }
237
- 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');
238
288
  if (this.preventDataOps) {
239
289
  return;
240
290
  }
241
291
  var col = 0;
242
292
  var row = 0;
243
- var wrapBox = this.element.getBoundingClientRect();
293
+ var wrapBox = this.$el.getBoundingClientRect();
244
294
  if (dX > wrapBox.width / this.$props.defaultPosition.colSpan / 3) {
245
295
  col = 1;
246
296
  }
@@ -255,48 +305,49 @@ var TileVue2 = {
255
305
  row = -1;
256
306
  }
257
307
  if (col !== 0 || row !== 0) {
258
- this.$props.update(this.$props.index, 0, 0, row, col);
308
+ this.$emit('update', this.$props.index, 0, 0, row, col);
259
309
  }
260
310
  },
261
311
  handlePress: function handlePress(e) {
262
- if (!this.dragElement) {
312
+ var dragElement = this.dragElement();
313
+ if (!this.reorderable || !dragElement) {
263
314
  return;
264
315
  }
265
316
  this.ignoreDrag = false;
266
- if (this.$props.ignoreDrag && this.$props.ignoreDrag(e.event.originalEvent)) {
317
+ if (this.$props.ignoreDrag && this.$props.ignoreDrag(e.originalEvent)) {
267
318
  this.ignoreDrag = true;
268
319
  return;
269
320
  }
270
- if (this.element) {
271
- this.element.style.zIndex = '10';
272
- 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');
273
324
  }
274
- this.dragElement.classList.remove('k-cursor-grab');
275
- this.dragElement.classList.add('k-cursor-grabbing');
276
- var rec = this.dragElement.getBoundingClientRect();
325
+ dragElement.classList.remove('k-cursor-grab');
326
+ dragElement.classList.add('k-cursor-grabbing');
327
+ var rec = dragElement.getBoundingClientRect();
277
328
  this.pressXY = {
278
- x: e.event.clientX,
279
- y: e.event.clientY
329
+ x: e.clientX,
330
+ y: e.clientY
280
331
  };
281
332
  this.pressOffset = {
282
- x: e.event.clientX - rec.x,
283
- y: e.event.clientY - rec.y
333
+ x: e.clientX - rec.x,
334
+ y: e.clientY - rec.y
284
335
  };
285
336
  },
286
337
  handleDrag: function handleDrag(e) {
287
- if (this.ignoreDrag) {
338
+ if (!this.reorderable || this.ignoreDrag) {
288
339
  return;
289
340
  }
290
- var dragElement = this.dragElement;
291
- if (e.event.originalEvent.defaultPrevented || !dragElement) {
341
+ var dragElement = this.dragElement();
342
+ if (e.originalEvent.defaultPrevented || !dragElement) {
292
343
  return;
293
344
  }
294
345
  this.dragging = true;
295
- e.event.originalEvent.preventDefault();
346
+ e.originalEvent.preventDefault();
296
347
  var rec = dragElement.getBoundingClientRect();
297
348
  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
349
+ x: e.clientX - rec.x - this.pressOffset.x + this.currentTranslate.x,
350
+ y: e.clientY - rec.y - this.pressOffset.y + this.currentTranslate.y
300
351
  };
301
352
  dragElement.style.transform = "translate(".concat(this.currentTranslate.x, "px, ").concat(this.currentTranslate.y, "px)");
302
353
  dragElement.style.transition = 'transform 0s';
@@ -317,7 +368,7 @@ var TileVue2 = {
317
368
  if (this.currentTranslate.x < 0.7 * -rec.width / this.$props.defaultPosition.colSpan) {
318
369
  col = -1;
319
370
  }
320
- 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);
321
372
  },
322
373
  handleRelease: function handleRelease() {
323
374
  this.dragging = this.resizing = false;
@@ -325,11 +376,11 @@ var TileVue2 = {
325
376
  x: 0,
326
377
  y: 0
327
378
  };
328
- if (this.element) {
329
- this.element.style.zIndex = '1';
330
- 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');
331
382
  }
332
- var dragElement = this.dragElement;
383
+ var dragElement = this.dragElement();
333
384
  if (dragElement) {
334
385
  dragElement.style.transform = 'translate(0px, 0px)';
335
386
  dragElement.style.transition = "transform ".concat(ANIMATION_DURATION, "ms cubic-bezier(0.2, 0, 0, 1) 0s");
@@ -341,18 +392,7 @@ var TileVue2 = {
341
392
  }
342
393
  }
343
394
  }
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
395
  };
355
-
356
396
  exports.TileVue2 = TileVue2;
357
397
  /**
358
398
  * @hidden