@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.
@@ -1,21 +1,9 @@
1
- var __assign = this && this.__assign || function () {
2
- __assign = Object.assign || function (t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) {
6
- if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
7
- }
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
1
  // @ts-ignore
14
2
  import * as Vue from 'vue';
15
3
  var allVue = Vue;
16
4
  var gh = allVue.h;
17
5
  var isV3 = allVue.version && allVue.version[0] === '3';
18
- import { getter, classNames, validatePackage } from '@progress/kendo-vue-common';
6
+ import { getListeners, getTemplate, getter, templateRendering, validatePackage } from '@progress/kendo-vue-common';
19
7
  import { packageMetadata } from '../package-metadata.js';
20
8
  import { Tile } from './Tile.js';
21
9
  /**
@@ -49,16 +37,37 @@ var TileLayoutVue2 = {
49
37
  validator: function validator(value) {
50
38
  return ['column', 'row', 'column dense', 'row dense', 'unset'].includes(value);
51
39
  }
52
- }
53
- // onReposition: PropTypes.func,
54
- // ignoreDrag: PropTypes.func
40
+ },
41
+ ignoreDrag: Function
55
42
  },
56
-
57
43
  created: function created() {
58
44
  validatePackage(packageMetadata);
59
45
  },
46
+ data: function data() {
47
+ return {
48
+ currentPositions: []
49
+ };
50
+ },
60
51
  computed: {
61
- positions: function positions() {
52
+ compPositions: function compPositions() {
53
+ if (this.positions) {
54
+ return this.positions.map(function (p, i) {
55
+ return Object.assign({
56
+ order: i,
57
+ rowSpan: 1,
58
+ colSpan: 1
59
+ }, p);
60
+ });
61
+ }
62
+ if (this.items && this.currentPositions.length) {
63
+ return this.currentPositions.map(function (p, i) {
64
+ return Object.assign({
65
+ order: i,
66
+ rowSpan: 1,
67
+ colSpan: 1
68
+ }, p);
69
+ });
70
+ }
62
71
  return (this.$props.items || []).map(function (p, i) {
63
72
  return Object.assign({
64
73
  order: i,
@@ -66,65 +75,15 @@ var TileLayoutVue2 = {
66
75
  colSpan: 1
67
76
  }, p.defaultPosition);
68
77
  });
78
+ },
79
+ wrapperClass: function wrapperClass() {
80
+ var _a;
81
+ var autoFlow = this.$props.autoFlow;
82
+ return _a = {
83
+ 'k-tilelayout': true
84
+ }, _a[AUTO_FLOW_CLASSES[autoFlow]] = true, _a;
69
85
  }
70
86
  },
71
- // /**
72
- // * @hidden
73
- // */
74
- // static getDerivedStateFromProps(props: TileLayoutProps, state: TileLayoutState) {
75
- // if (props.positions) {
76
- // // The component is in controlled mode.
77
- // return {
78
- // positions: props.positions.map((p, i) => (Object.assign({ order: i, rowSpan: 1, colSpan: 1 }, p)))
79
- // };
80
- // }
81
- // if (props.items && (!state.positions || (props.items.length !== state.positions.length))) {
82
- // // The component is in uncontrolled mode.
83
- // return {
84
- // positions: props.items.map((p, i) => (Object.assign(
85
- // { order: i, rowSpan: 1, colSpan: 1 }, p.defaultPosition)))
86
- // };
87
- // }
88
- // return null;
89
- // }
90
- // /**
91
- // * @hidden
92
- // */
93
- // update = (index: number, dOrder: number, dCol: number, dRowSpan = 0, dColSpan = 0) => {
94
- // if (dOrder === 0 && dCol === 0 && !dColSpan && !dRowSpan) {
95
- // return;
96
- // }
97
- // let shouldUpdate = false;
98
- // const positions: Array<TileStrictPosition> = this.state.positions.map(p => Object.assign({}, p));
99
- // // reordering:
100
- // const current = positions[index];
101
- // const other = positions.find(item => (item.order === current.order + dOrder));
102
- // if (other && other !== current) {
103
- // current.order += dOrder;
104
- // other.order += -dOrder;
105
- // shouldUpdate = true;
106
- // }
107
- // const proposedCol = current.col + dCol;
108
- // if (dCol !== 0 && proposedCol >= 1 && proposedCol + current.colSpan <= (this.$props.columns || 3) + 1) {
109
- // current.col = proposedCol;
110
- // shouldUpdate = true;
111
- // }
112
- // // resizing:
113
- // const proposedColSpan = current.colSpan + dColSpan;
114
- // if (dColSpan && proposedColSpan >= 1 && proposedColSpan + current.col <= (this.$props.columns || 3) + 1) {
115
- // current.colSpan = proposedColSpan;
116
- // shouldUpdate = true;
117
- // }
118
- // const proposedRowSpan = current.rowSpan + dRowSpan;
119
- // if (dRowSpan && proposedRowSpan >= 1) {
120
- // current.rowSpan = proposedRowSpan;
121
- // shouldUpdate = true;
122
- // }
123
- // if (shouldUpdate) {
124
- // this.setState({ positions: positions });
125
- // dispatchEvent(this.$props.onReposition, {} as any, this, { value: positions });
126
- // }
127
- // };
128
87
  // @ts-ignore
129
88
  setup: !isV3 ? undefined : function () {
130
89
  var v3 = !!isV3;
@@ -135,7 +94,6 @@ var TileLayoutVue2 = {
135
94
  render: function render(createElement) {
136
95
  var h = gh || createElement;
137
96
  var _a = this.$props,
138
- className = _a.className,
139
97
  _b = _a.columns,
140
98
  columns = _b === void 0 ? 3 : _b,
141
99
  _c = _a.columnWidth,
@@ -143,67 +101,88 @@ var TileLayoutVue2 = {
143
101
  gap = _a.gap,
144
102
  _d = _a.rowHeight,
145
103
  rowHeight = _d === void 0 ? '1fr' : _d,
146
- style = _a.style,
147
- _e = _a.autoFlow,
148
- autoFlow = _e === void 0 ? 'column' : _e,
149
- _f = _a.items,
150
- items = _f === void 0 ? [] : _f;
104
+ _e = _a.items,
105
+ items = _e === void 0 ? [] : _e;
151
106
  var gapValue = gap ? "".concat(typeof gap.rows === 'number' ? gap.rows + 'px' : gap.rows) + ' ' + "".concat(typeof gap.columns === 'number' ? gap.columns + 'px' : gap.columns) : 16;
152
- var tileLayoutStyles = __assign({
107
+ var tileLayoutStyles = {
153
108
  gridTemplateColumns: "repeat(".concat(columns, ", minmax(0px, ").concat(typeof columnWidth === 'number' ? columnWidth + 'px' : columnWidth, "))"),
154
109
  gridAutoRows: "minmax(0px, ".concat(typeof rowHeight === 'number' ? rowHeight + 'px' : rowHeight, ")"),
155
110
  gap: gapValue,
156
111
  padding: gapValue
157
- }, style);
112
+ };
158
113
  return h("div", {
159
114
  dir: this.$props.dir,
160
115
  attrs: this.v3 ? undefined : {
161
116
  dir: this.$props.dir,
162
117
  id: this.$props.id
163
118
  },
164
- "class": classNames('k-tilelayout', AUTO_FLOW_CLASSES[autoFlow], className),
119
+ "class": this.wrapperClass,
165
120
  style: tileLayoutStyles,
166
121
  id: this.$props.id
167
122
  }, [items.map(function (tile, index) {
123
+ var item = templateRendering.call(this, tile.item, getListeners.call(this));
124
+ var itemContent = getTemplate.call(this, {
125
+ h: h,
126
+ template: item,
127
+ defaultRendering: null
128
+ });
129
+ var header = templateRendering.call(this, tile.header, getListeners.call(this));
130
+ var headerContent = getTemplate.call(this, {
131
+ h: h,
132
+ template: header,
133
+ defaultRendering: null
134
+ });
135
+ var body = templateRendering.call(this, tile.body, getListeners.call(this));
136
+ var bodyContent = getTemplate.call(this, {
137
+ h: h,
138
+ template: body,
139
+ defaultRendering: null
140
+ });
168
141
  return (
169
142
  // @ts-ignore function children
170
143
  h(Tile, {
171
144
  key: this.$props.dataItemKey ? getter(this.$props.dataItemKey)(tile) : index,
172
- update: this.update,
145
+ onUpdate: this.updateHandle,
146
+ on: this.v3 ? undefined : {
147
+ "update": this.updateHandle
148
+ },
149
+ defaultPosition: this.compPositions[index],
173
150
  attrs: this.v3 ? undefined : {
174
- update: this.update,
175
- defaultPosition: this.state.positions[index],
151
+ defaultPosition: this.compPositions[index],
176
152
  index: index,
177
153
  resizable: tile.resizable,
178
154
  reorderable: tile.reorderable,
179
- hintClassName: tile.hintClassName,
155
+ hintClass: tile.hintClass,
180
156
  hintStyle: tile.hintStyle,
181
157
  ignoreDrag: this.$props.ignoreDrag
182
158
  },
183
- defaultPosition: this.state.positions[index],
184
159
  index: index,
185
160
  resizable: tile.resizable,
186
161
  reorderable: tile.reorderable,
187
162
  style: tile.style,
188
- "class": tile.className,
189
- hintClassName: tile.hintClassName,
163
+ "class": tile.class,
164
+ hintClass: tile.hintClass,
190
165
  hintStyle: tile.hintStyle,
191
166
  ignoreDrag: this.$props.ignoreDrag
192
167
  }, this.v3 ? function () {
193
- return [tile.item ? tile.item : [h("div", {
168
+ return [tile.item ? {
169
+ itemContent: itemContent
170
+ } : [h("div", {
194
171
  "class": "k-tilelayout-item-header k-card-header"
195
- }, [tile.header ? tile.header : h("h5", {
172
+ }, [tile.header ? headerContent : h("h5", {
196
173
  "class": 'k-card-title'
197
- }, [tile.header])]), h("div", {
174
+ }, [tile.headerText])]), h("div", {
198
175
  "class": 'k-tilelayout-item-body k-card-body'
199
- }, [tile.body])]];
200
- } : [tile.item ? tile.item : [h("div", {
176
+ }, [tile.body ? bodyContent : tile.bodyText])]];
177
+ } : [tile.item ? {
178
+ itemContent: itemContent
179
+ } : [h("div", {
201
180
  "class": "k-tilelayout-item-header k-card-header"
202
- }, [tile.header ? tile.header : h("h5", {
181
+ }, [tile.header ? headerContent : h("h5", {
203
182
  "class": 'k-card-title'
204
- }, [tile.header])]), h("div", {
183
+ }, [tile.headerText])]), h("div", {
205
184
  "class": 'k-tilelayout-item-body k-card-body'
206
- }, [tile.body])]])
185
+ }, [tile.body ? bodyContent : tile.bodyText])]])
207
186
  );
208
187
  }, this)]);
209
188
  },
@@ -212,6 +191,53 @@ var TileLayoutVue2 = {
212
191
  if (this.$el) {
213
192
  this.$el.focus();
214
193
  }
194
+ },
195
+ updateHandle: function updateHandle(index, dOrder, dCol, dRowSpan, dColSpan) {
196
+ if (dRowSpan === void 0) {
197
+ dRowSpan = 0;
198
+ }
199
+ if (dColSpan === void 0) {
200
+ dColSpan = 0;
201
+ }
202
+ if (dOrder === 0 && dCol === 0 && !dColSpan && !dRowSpan) {
203
+ return;
204
+ }
205
+ var shouldUpdate = false;
206
+ var positions = this.compPositions.map(function (p) {
207
+ return Object.assign({}, p);
208
+ });
209
+ // reordering:
210
+ var current = positions[index];
211
+ var other = positions.find(function (item) {
212
+ return item.order === current.order + dOrder;
213
+ });
214
+ if (other && other !== current) {
215
+ current.order += dOrder;
216
+ other.order += -dOrder;
217
+ shouldUpdate = true;
218
+ }
219
+ var proposedCol = current.col + dCol;
220
+ if (dCol !== 0 && proposedCol >= 1 && proposedCol + current.colSpan <= (this.$props.columns || 3) + 1) {
221
+ current.col = proposedCol;
222
+ shouldUpdate = true;
223
+ }
224
+ // resizing:
225
+ var proposedColSpan = current.colSpan + dColSpan;
226
+ if (dColSpan && proposedColSpan >= 1 && proposedColSpan + current.col <= (this.$props.columns || 3) + 1) {
227
+ current.colSpan = proposedColSpan;
228
+ shouldUpdate = true;
229
+ }
230
+ var proposedRowSpan = current.rowSpan + dRowSpan;
231
+ if (dRowSpan && proposedRowSpan >= 1) {
232
+ current.rowSpan = proposedRowSpan;
233
+ shouldUpdate = true;
234
+ }
235
+ if (shouldUpdate) {
236
+ this.currentPositions = positions;
237
+ this.$emit('reposition', {
238
+ value: positions
239
+ });
240
+ }
215
241
  }
216
242
  }
217
243
  };
@@ -7,10 +7,14 @@ export interface TileLayoutItem {
7
7
  * ([see example]({% slug tiles_tilelayout %}#toc-position-and-dimensions)).
8
8
  */
9
9
  defaultPosition?: TilePosition;
10
+ /**
11
+ * Sets additional styles to the TileLayoutItem.
12
+ */
13
+ style?: object;
10
14
  /**
11
15
  * Sets additional classes to the TileLayoutItem.
12
16
  */
13
- className?: string;
17
+ class?: string;
14
18
  /**
15
19
  * Sets additional CSS styles to the TileLayoutItem hint element.
16
20
  */
@@ -18,17 +22,27 @@ export interface TileLayoutItem {
18
22
  /**
19
23
  * Sets additional classes to the TileLayoutItem hint element.
20
24
  */
21
- hintClassName?: string;
25
+ hintClass?: string;
22
26
  /**
23
- * Sets the title in the TileLayoutItem's header
27
+ * Sets the title in the TileLayoutItem's header content
24
28
  * ([see example]({% slug tiles_tilelayout %})).
25
29
  */
26
30
  header?: any;
27
31
  /**
28
- * Sets the content in TileLayoutItem's body
32
+ * Sets the title in the TileLayoutItem's header text
33
+ * ([see example]({% slug tiles_tilelayout %})).
34
+ */
35
+ headerText?: string;
36
+ /**
37
+ * Sets the content in TileLayoutItem's body content
29
38
  * ([see example]({% slug tiles_tilelayout %})).
30
39
  */
31
40
  body?: any;
41
+ /**
42
+ * Sets the content in TileLayoutItem's body text
43
+ * ([see example]({% slug tiles_tilelayout %})).
44
+ */
45
+ bodyText?: string;
32
46
  /**
33
47
  * Overrides the default rendering of the TileLayoutItem
34
48
  * ([see example]({% slug tiles_tilelayout %}#toc-custom-rendering)).
@@ -8,7 +8,7 @@ exports.packageMetadata = {
8
8
  name: '@progress/kendo-vue-layout',
9
9
  productName: 'Kendo UI for Vue',
10
10
  productCodes: ['KENDOUIVUE', 'KENDOUICOMPLETE'],
11
- publishDate: 1668069369,
11
+ publishDate: 1669818334,
12
12
  version: '',
13
13
  licensingDocsUrl: 'https://www.telerik.com/kendo-vue-ui/my-license/?utm_medium=product&utm_source=kendovue&utm_campaign=kendo-ui-vue-purchase-license-keys-warning'
14
14
  };
@@ -7,7 +7,7 @@ import { DefineComponent, RecordPropsDefinition, ComponentOptions, Vue2type } fr
7
7
  * @hidden
8
8
  */
9
9
  export interface ResizeHandlersProps {
10
- resizable: string | boolean;
10
+ direction: string;
11
11
  onResize?: (e: any, args: {
12
12
  end: boolean;
13
13
  direction: any;
@@ -1,5 +1,17 @@
1
1
  "use strict";
2
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
+ };
3
15
  Object.defineProperty(exports, "__esModule", {
4
16
  value: true
5
17
  });
@@ -9,15 +21,64 @@ var Vue = require("vue");
9
21
  var allVue = Vue;
10
22
  var gh = allVue.h;
11
23
  var isV3 = allVue.version && allVue.version[0] === '3';
24
+ var kendo_vue_common_1 = require("@progress/kendo-vue-common");
12
25
  /**
13
26
  * @hidden
14
27
  */
15
28
  var ResizeHandlersVue2 = {
16
29
  name: 'KendoResizeHandlers',
17
30
  props: {
18
- resizable: [String, Boolean],
31
+ direction: String,
19
32
  rtl: Boolean
20
33
  },
34
+ computed: {
35
+ handleClass: function handleClass() {
36
+ return 'k-resize-handle k-cursor-' + this.direction + '-resize';
37
+ },
38
+ dirStyles: function dirStyles() {
39
+ var direction = this.$props.direction;
40
+ switch (direction) {
41
+ case 'ew':
42
+ return this.rtl ? {
43
+ top: 0,
44
+ width: '9px',
45
+ left: 0,
46
+ right: ''
47
+ } : {
48
+ top: 0,
49
+ width: '9px',
50
+ right: 0,
51
+ left: ''
52
+ };
53
+ case 'ns':
54
+ return {
55
+ left: 0,
56
+ height: '9px'
57
+ };
58
+ case 'nesw':
59
+ case 'nwse':
60
+ return this.rtl ? {
61
+ width: '9px',
62
+ height: '9px',
63
+ right: '',
64
+ left: 0
65
+ } : {
66
+ width: '9px',
67
+ height: '9px',
68
+ right: 0,
69
+ left: ''
70
+ };
71
+ default:
72
+ return {};
73
+ }
74
+ },
75
+ handleStyle: function handleStyle() {
76
+ return __assign({
77
+ bottom: 0,
78
+ right: 0
79
+ }, this.dirStyles);
80
+ }
81
+ },
21
82
  // @ts-ignore
22
83
  setup: !isV3 ? undefined : function () {
23
84
  var v3 = !!isV3;
@@ -26,55 +87,50 @@ var ResizeHandlersVue2 = {
26
87
  };
27
88
  },
28
89
  render: function render(createElement) {
90
+ var _this2 = this;
91
+ var _this = this;
29
92
  var h = gh || createElement;
30
- var _a = this.$props,
31
- resizable = _a.resizable,
32
- onPress = _a.onPress,
33
- rtl = _a.rtl;
34
- if (!resizable) {
35
- return null;
36
- }
37
- // const Handle = (props: { onResize: any; style: {}; d: string; onPress: any }) => (
38
- // // @ts-ignore
39
- // <Draggable
40
- // onPress={props.onPress}
41
- // onDrag={(data: any) => { props.onResize(data.event, false, props.d); }}
42
- // onRelease={(data: any) => { props.onResize(data.event, true, props.d); }}
43
- // >
44
- // <div className={'k-resize-handle k-cursor-' + props.d + '-resize'}
45
- // style={{ bottom: 0, right: 0, ...props.style }} />
46
- // </Draggable>
47
- // );
48
- return h("div")
49
- // <React.Fragment>
50
- // {resizable !== 'vertical' && (
51
- // <Handle
52
- // onPress={onPress}
53
- // onResize={this.handleResize}
54
- // d="ew"
55
- // style={rtl ? { top: 0, width: 9, left: 0, right: '' } : { top: 0, width: 9, right: 0, left: '' }}
56
- // />
57
- // )}
58
- // {resizable !== 'horizontal' && (
59
- // <Handle onPress={onPress} onResize={this.handleResize} d="ns" style={{ left: 0, height: 9 }} />)}
60
- // {(resizable === true) && (
61
- // <Handle
62
- // onPress={onPress}
63
- // onResize={this.handleResize}
64
- // d={rtl ? 'nesw' : 'nwse'}
65
- // style={rtl ? { width: 9, height: 9, right: '', left: 0 } : { width: 9, height: 9, right: 0, left: '' }}
66
- // />)}
67
- // </React.Fragment>
68
- ;
93
+ var direction = this.$props.direction;
94
+ return (
95
+ // @ts-ignore function children
96
+ h(kendo_vue_common_1.Draggable, {
97
+ onPress: this.handlePress,
98
+ on: this.v3 ? undefined : {
99
+ "press": this.handlePress,
100
+ "drag": function drag(event) {
101
+ _this.handleResize(event, false, direction);
102
+ },
103
+ "release": function release(event) {
104
+ _this.handleResize(event, true, direction);
105
+ }
106
+ },
107
+ onDrag: function drag(event) {
108
+ _this.handleResize(event, false, direction);
109
+ },
110
+ onRelease: function release(event) {
111
+ _this.handleResize(event, true, direction);
112
+ }
113
+ }, this.v3 ? function () {
114
+ return [h("div", {
115
+ "class": _this2.handleClass,
116
+ style: _this2.handleStyle
117
+ })];
118
+ } : [h("div", {
119
+ "class": _this2.handleClass,
120
+ style: _this2.handleStyle
121
+ })])
122
+ );
69
123
  },
70
-
71
124
  methods: {
72
125
  handleResize: function handleResize(event, isEnd, direction) {
73
126
  event.originalEvent.preventDefault();
74
- this.$props.onResize(event, {
127
+ this.$emit('resize', event, {
75
128
  end: isEnd,
76
129
  direction: direction
77
130
  });
131
+ },
132
+ handlePress: function handlePress(event) {
133
+ this.$emit('press', event);
78
134
  }
79
135
  }
80
136
  };