vgapp 1.4.7 → 1.4.9
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/README.md +24 -2
- package/app/modules/base-module.js +14 -2
- package/app/modules/module-fn.js +5 -4
- package/app/modules/vgalert/js/vgalert.js +21 -1
- package/app/modules/vgalert/scss/vgalert.scss +48 -0
- package/app/modules/vgdropdown/js/vgdropdown.js +58 -27
- package/app/modules/vgfilepreview/js/renderers/video-modal.js +5 -1
- package/app/modules/vgfilepreview/js/renderers/video.js +6 -1
- package/app/modules/vgfilepreview/js/vgfilepreview.js +5 -1
- package/app/modules/vgfiles/js/base.js +14 -5
- package/app/modules/vgfiles/js/droppable.js +37 -31
- package/app/modules/vgfiles/js/vgfiles.js +5 -2
- package/app/modules/vgfiles/scss/_variables.scss +3 -1
- package/app/modules/vgfiles/scss/vgfiles.scss +55 -10
- package/app/modules/vgformsender/js/vgformsender.js +5 -2
- package/app/modules/vgloadmore/js/vgloadmore.js +35 -7
- package/app/modules/vgnestable/js/vgnestable.js +140 -0
- package/app/modules/vgnestable/scss/_variables.scss +16 -9
- package/app/modules/vgnestable/scss/vgnestable.scss +35 -2
- package/app/modules/vgtable/index.js +3 -0
- package/app/modules/vgtable/js/_columns.js +567 -0
- package/app/modules/vgtable/js/_expandable.js +242 -0
- package/app/modules/vgtable/js/_filters.js +264 -0
- package/app/modules/vgtable/js/_fixed-columns.js +249 -0
- package/app/modules/vgtable/js/_i18n.js +75 -0
- package/app/modules/vgtable/js/_options.js +428 -0
- package/app/modules/vgtable/js/_pagination.js +491 -0
- package/app/modules/vgtable/js/_panning.js +124 -0
- package/app/modules/vgtable/js/_params-groups.js +21 -0
- package/app/modules/vgtable/js/_remote.js +395 -0
- package/app/modules/vgtable/js/_row-reorder.js +268 -0
- package/app/modules/vgtable/js/_search.js +134 -0
- package/app/modules/vgtable/js/_selection.js +113 -0
- package/app/modules/vgtable/js/_skeleton.js +123 -0
- package/app/modules/vgtable/js/_sorting.js +340 -0
- package/app/modules/vgtable/js/_states.js +143 -0
- package/app/modules/vgtable/js/_sticky-header.js +193 -0
- package/app/modules/vgtable/js/_url-state.js +178 -0
- package/app/modules/vgtable/js/vgtable.js +1444 -0
- package/app/modules/vgtable/readme.md +922 -0
- package/app/modules/vgtable/scss/_columns.scss +52 -0
- package/app/modules/vgtable/scss/_expandable.scss +54 -0
- package/app/modules/vgtable/scss/_fixed-columns.scss +117 -0
- package/app/modules/vgtable/scss/_pagination.scss +191 -0
- package/app/modules/vgtable/scss/_row-reorder.scss +45 -0
- package/app/modules/vgtable/scss/_skeleton.scss +65 -0
- package/app/modules/vgtable/scss/_sorting.scss +89 -0
- package/app/modules/vgtable/scss/_states.scss +70 -0
- package/app/modules/vgtable/scss/_sticky-header.scss +121 -0
- package/app/modules/vgtable/scss/_variables.scss +296 -0
- package/app/modules/vgtable/scss/vgtable.scss +206 -0
- package/app/utils/js/components/placement.js +64 -10
- package/app/vgapp.js +3 -3
- package/build/vgapp.css +1 -1
- package/build/vgapp.css.map +1 -1
- package/build/vgapp.js +1 -1
- package/build/vgapp.js.map +1 -1
- package/index.js +1 -1
- package/index.scss +3 -3
- package/package.json +5 -5
- package/app/modules/vgdynamictable/index.js +0 -4
- package/app/modules/vgdynamictable/js/editable.js +0 -438
- package/app/modules/vgdynamictable/js/expandable.js +0 -248
- package/app/modules/vgdynamictable/js/filters.js +0 -450
- package/app/modules/vgdynamictable/js/fixed.js +0 -566
- package/app/modules/vgdynamictable/js/options.js +0 -650
- package/app/modules/vgdynamictable/js/pagination.js +0 -623
- package/app/modules/vgdynamictable/js/search.js +0 -82
- package/app/modules/vgdynamictable/js/skeleton.js +0 -144
- package/app/modules/vgdynamictable/js/sortable.js +0 -442
- package/app/modules/vgdynamictable/js/summary-footer.js +0 -284
- package/app/modules/vgdynamictable/js/table-remote.js +0 -821
- package/app/modules/vgdynamictable/js/table-state.js +0 -243
- package/app/modules/vgdynamictable/js/table-url-state.js +0 -444
- package/app/modules/vgdynamictable/js/utils/common.js +0 -48
- package/app/modules/vgdynamictable/js/vgdynamictable.js +0 -3870
- package/app/modules/vgdynamictable/js/viewport.js +0 -322
- package/app/modules/vgdynamictable/readme.md +0 -251
- package/app/modules/vgdynamictable/scss/_actions.scss +0 -196
- package/app/modules/vgdynamictable/scss/_pagination.scss +0 -186
- package/app/modules/vgdynamictable/scss/_skeleton.scss +0 -63
- package/app/modules/vgdynamictable/scss/_sortable.scss +0 -66
- package/app/modules/vgdynamictable/scss/_table.scss +0 -137
- package/app/modules/vgdynamictable/scss/_variables.scss +0 -138
- package/app/modules/vgdynamictable/scss/vgdynamictable.scss +0 -264
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Описание: расчёт позиции всплывающих элементов относительно триггера и доступных границ.
|
|
3
|
+
* Возможности: auto-flip, clipping-родители, ограничение координат и позиционирование внутри offsetParent.
|
|
4
|
+
*/
|
|
1
5
|
import {mergeDeepObject} from "../functions";
|
|
2
6
|
|
|
3
7
|
class Placement {
|
|
@@ -36,18 +40,20 @@ class Placement {
|
|
|
36
40
|
_getOverflowConstraints() {
|
|
37
41
|
const refRect = this._getPlacementRect(this.reference);
|
|
38
42
|
const dropRect = this._getPlacementRect(this.drop);
|
|
39
|
-
const
|
|
43
|
+
const boundaryRect = this._getBoundaryRect();
|
|
40
44
|
const [xOffset, yOffset] = this.offset;
|
|
41
45
|
|
|
42
46
|
let placement = this.placement;
|
|
43
47
|
|
|
44
48
|
if (this.overflowProtection) {
|
|
45
|
-
const fallbacks =
|
|
49
|
+
const fallbacks = this.autoFlip
|
|
50
|
+
? Array.from(new Set([this.placement, ...this.fallbackPlacements]))
|
|
51
|
+
: [this.placement];
|
|
46
52
|
let best = null;
|
|
47
53
|
|
|
48
54
|
for (const p of fallbacks) {
|
|
49
55
|
const position = this._calculatePosition(p, refRect, dropRect, xOffset, yOffset);
|
|
50
|
-
const overflow = this._calculateOverflow(position, dropRect,
|
|
56
|
+
const overflow = this._calculateOverflow(position, dropRect, boundaryRect);
|
|
51
57
|
|
|
52
58
|
if (!best || overflow < best.overflow) {
|
|
53
59
|
best = { placement: p, position, overflow };
|
|
@@ -59,7 +65,7 @@ class Placement {
|
|
|
59
65
|
placement = best.placement;
|
|
60
66
|
|
|
61
67
|
const finalPosition = this.clamp
|
|
62
|
-
? this._clampPosition(best.position, dropRect,
|
|
68
|
+
? this._clampPosition(best.position, dropRect, boundaryRect)
|
|
63
69
|
: best.position;
|
|
64
70
|
|
|
65
71
|
this._setStyles(finalPosition);
|
|
@@ -67,7 +73,7 @@ class Placement {
|
|
|
67
73
|
const position = this._calculatePosition(placement, refRect, dropRect, xOffset, yOffset);
|
|
68
74
|
|
|
69
75
|
const finalPosition = this.clamp
|
|
70
|
-
? this._clampPosition(position, dropRect,
|
|
76
|
+
? this._clampPosition(position, dropRect, boundaryRect)
|
|
71
77
|
: position;
|
|
72
78
|
|
|
73
79
|
this._setStyles(finalPosition);
|
|
@@ -76,6 +82,46 @@ class Placement {
|
|
|
76
82
|
this.drop.setAttribute('data-vg-placement', placement);
|
|
77
83
|
}
|
|
78
84
|
|
|
85
|
+
_getBoundaryRect() {
|
|
86
|
+
const viewport = this._getViewportRect();
|
|
87
|
+
if (this.boundary instanceof Element) {
|
|
88
|
+
return this._intersectRects(viewport, this._getPlacementRect(this.boundary));
|
|
89
|
+
}
|
|
90
|
+
if (typeof this.boundary === 'string' && this.boundary !== 'viewport' && this.boundary !== 'clippingParents') {
|
|
91
|
+
const boundary = this.reference.closest(this.boundary);
|
|
92
|
+
if (boundary) return this._intersectRects(viewport, this._getPlacementRect(boundary));
|
|
93
|
+
}
|
|
94
|
+
if (this.boundary !== 'clippingParents') return viewport;
|
|
95
|
+
|
|
96
|
+
let result = viewport;
|
|
97
|
+
let parent = this.reference.parentElement;
|
|
98
|
+
while (parent && parent !== document.body && parent !== document.documentElement) {
|
|
99
|
+
if (this._isClippingElement(parent)) {
|
|
100
|
+
result = this._intersectRects(result, this._getPlacementRect(parent));
|
|
101
|
+
}
|
|
102
|
+
parent = parent.parentElement;
|
|
103
|
+
}
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
_isClippingElement(element) {
|
|
108
|
+
const style = window.getComputedStyle(element);
|
|
109
|
+
return [style.overflow, style.overflowX, style.overflowY]
|
|
110
|
+
.some((value) => /(auto|scroll|hidden|clip)/.test(value || ''));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
_intersectRects(left, right) {
|
|
114
|
+
const result = {
|
|
115
|
+
left: Math.max(left.left, right.left),
|
|
116
|
+
top: Math.max(left.top, right.top),
|
|
117
|
+
right: Math.min(left.right, right.right),
|
|
118
|
+
bottom: Math.min(left.bottom, right.bottom),
|
|
119
|
+
};
|
|
120
|
+
result.width = Math.max(0, result.right - result.left);
|
|
121
|
+
result.height = Math.max(0, result.bottom - result.top);
|
|
122
|
+
return result;
|
|
123
|
+
}
|
|
124
|
+
|
|
79
125
|
_calculatePosition(placement, refRect, dropRect, xOffset = 0, yOffset = 0) {
|
|
80
126
|
let top;
|
|
81
127
|
let left;
|
|
@@ -191,18 +237,26 @@ class Placement {
|
|
|
191
237
|
|
|
192
238
|
_setStyles(pos) {
|
|
193
239
|
if (!pos || !this.drop) return;
|
|
240
|
+
const offsetParent = this.drop.offsetParent;
|
|
241
|
+
let top = pos.top + window.pageYOffset;
|
|
242
|
+
let left = pos.left + window.pageXOffset;
|
|
243
|
+
if (offsetParent && offsetParent !== document.body && offsetParent !== document.documentElement) {
|
|
244
|
+
const parentRect = this._getPlacementRect(offsetParent);
|
|
245
|
+
top = pos.top - parentRect.top + offsetParent.scrollTop - offsetParent.clientTop;
|
|
246
|
+
left = pos.left - parentRect.left + offsetParent.scrollLeft - offsetParent.clientLeft;
|
|
247
|
+
}
|
|
194
248
|
|
|
195
249
|
if (this.isMerge) {
|
|
196
250
|
mergeDeepObject(this.drop.style, {
|
|
197
251
|
position: 'absolute',
|
|
198
|
-
top: `${
|
|
199
|
-
left: `${
|
|
252
|
+
top: `${top}px`,
|
|
253
|
+
left: `${left}px`,
|
|
200
254
|
margin: '0'
|
|
201
255
|
});
|
|
202
256
|
} else {
|
|
203
257
|
this.drop.style.position = 'absolute';
|
|
204
|
-
this.drop.style.top = `${
|
|
205
|
-
this.drop.style.left = `${
|
|
258
|
+
this.drop.style.top = `${top}px`;
|
|
259
|
+
this.drop.style.left = `${left}px`;
|
|
206
260
|
this.drop.style.margin = '0';
|
|
207
261
|
}
|
|
208
262
|
}
|
|
@@ -212,4 +266,4 @@ class Placement {
|
|
|
212
266
|
}
|
|
213
267
|
}
|
|
214
268
|
|
|
215
|
-
export default Placement;
|
|
269
|
+
export default Placement;
|
package/app/vgapp.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import VGAlert from './modules/vgalert';
|
|
2
2
|
import VGCollapse from './modules/vgcollapse';
|
|
3
3
|
import VGDropdown from './modules/vgdropdown';
|
|
4
|
-
import { Editable, VGDynamicTable } from './modules/vgdynamictable';
|
|
5
4
|
import VGFiles from './modules/vgfiles';
|
|
6
5
|
import VGFilePreview from './modules/vgfilepreview';
|
|
7
6
|
import VGFormSender from './modules/vgformsender';
|
|
@@ -16,6 +15,7 @@ import VGSelect from './modules/vgselect';
|
|
|
16
15
|
import VGSidebar from './modules/vgsidebar';
|
|
17
16
|
import VGSpy from './modules/vgspy';
|
|
18
17
|
import VGTabs from './modules/vgtabs';
|
|
18
|
+
import VGTable from "./modules/vgtable";
|
|
19
19
|
import VGToast from './modules/vgtoast';
|
|
20
20
|
import VGTooltip from './modules/vgtooltip';
|
|
21
21
|
|
|
@@ -264,7 +264,6 @@ const defaultModules = [
|
|
|
264
264
|
VGAlert,
|
|
265
265
|
VGCollapse,
|
|
266
266
|
VGDropdown,
|
|
267
|
-
VGDynamicTable,
|
|
268
267
|
VGFiles,
|
|
269
268
|
VGFilePreview,
|
|
270
269
|
VGFormSender,
|
|
@@ -279,6 +278,7 @@ const defaultModules = [
|
|
|
279
278
|
VGSidebar,
|
|
280
279
|
VGSpy,
|
|
281
280
|
VGTabs,
|
|
281
|
+
VGTable,
|
|
282
282
|
VGToast,
|
|
283
283
|
VGTooltip,
|
|
284
284
|
];
|
|
@@ -291,5 +291,5 @@ const vgapp = new VGApp({
|
|
|
291
291
|
},
|
|
292
292
|
});
|
|
293
293
|
|
|
294
|
-
export {
|
|
294
|
+
export { VGApp, vgapp };
|
|
295
295
|
export default vgapp;
|