@signal24/vue-foundation 3.8.1 → 4.0.0
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/.eslintrc.cjs +35 -0
- package/.prettierrc.json +4 -2
- package/dist/src/components/ajax-select.vue.d.ts +21 -0
- package/dist/src/components/alert-helpers.d.ts +8 -0
- package/dist/src/components/alert-modal.vue.d.ts +27 -0
- package/dist/src/components/ez-smart-select.vue.d.ts +27 -0
- package/dist/src/components/index.d.ts +8 -0
- package/dist/src/components/modal-container.d.ts +33 -0
- package/dist/src/components/modal.vue.d.ts +34 -0
- package/dist/src/components/smart-select.vue.d.ts +121 -0
- package/dist/src/config.d.ts +8 -0
- package/dist/src/directives/autofocus.d.ts +2 -0
- package/dist/src/directives/confirm-button.d.ts +2 -0
- package/dist/src/directives/date-input.d.ts +2 -0
- package/dist/src/directives/datetime.d.ts +2 -0
- package/dist/src/directives/disabled.d.ts +2 -0
- package/dist/src/directives/duration.d.ts +2 -0
- package/dist/src/directives/index.d.ts +24 -0
- package/dist/src/directives/infinite-scroll.d.ts +3 -0
- package/dist/src/directives/readonly.d.ts +2 -0
- package/dist/src/directives/tooltip.d.ts +41 -0
- package/dist/src/filters/index.d.ts +39 -0
- package/dist/src/helpers/array.d.ts +3 -0
- package/dist/src/helpers/context-menu.d.ts +13 -0
- package/dist/src/helpers/delay.d.ts +2 -0
- package/dist/src/helpers/error.d.ts +7 -0
- package/dist/src/helpers/index.d.ts +9 -0
- package/dist/src/helpers/mask.d.ts +15 -0
- package/dist/src/helpers/number.d.ts +1 -0
- package/dist/src/helpers/object.d.ts +2 -0
- package/dist/src/helpers/openapi.d.ts +34 -0
- package/dist/src/helpers/string.d.ts +5 -0
- package/dist/src/hooks/index.d.ts +2 -0
- package/dist/src/hooks/infinite-scroll.d.ts +30 -0
- package/dist/src/hooks/resize-watcher.d.ts +1 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/types.d.ts +14 -0
- package/dist/src/vite-plugins/index.d.ts +1 -0
- package/dist/src/vite-plugins/index.js +2 -0
- package/dist/src/vite-plugins/vite-openapi-plugin.d.ts +4 -0
- package/dist/src/vite-plugins/vite-openapi-plugin.js +58 -0
- package/dist/vue-foundation.css +1 -1
- package/dist/vue-foundation.es.js +880 -1880
- package/package.json +44 -16
- package/src/components/ajax-select.vue +44 -23
- package/src/components/alert-helpers.ts +45 -0
- package/src/components/alert-modal.vue +68 -0
- package/src/components/ez-smart-select.vue +51 -0
- package/src/components/index.ts +10 -0
- package/src/components/modal-container.ts +131 -0
- package/src/components/modal.vue +44 -129
- package/src/components/smart-select.vue +196 -243
- package/src/config.ts +15 -0
- package/src/directives/autofocus.ts +20 -0
- package/src/directives/confirm-button.ts +50 -0
- package/src/directives/date-input.ts +19 -0
- package/src/directives/datetime.ts +48 -0
- package/src/directives/disabled.ts +30 -0
- package/src/directives/duration.ts +79 -0
- package/src/directives/index.ts +37 -0
- package/src/directives/infinite-scroll.ts +9 -0
- package/src/directives/readonly.ts +15 -0
- package/src/directives/tooltip.ts +190 -0
- package/src/filters/index.ts +79 -0
- package/src/helpers/array.ts +7 -0
- package/src/helpers/context-menu.ts +108 -0
- package/src/helpers/delay.ts +2 -0
- package/src/helpers/error.ts +41 -0
- package/src/helpers/index.ts +9 -0
- package/src/helpers/mask.ts +105 -0
- package/src/helpers/number.ts +3 -0
- package/src/helpers/object.ts +19 -0
- package/src/helpers/openapi.ts +82 -0
- package/src/helpers/string.ts +27 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/infinite-scroll.ts +107 -0
- package/src/hooks/resize-watcher.ts +8 -0
- package/src/index.ts +14 -0
- package/src/types.ts +14 -0
- package/src/vite-plugins/index.ts +2 -0
- package/src/vite-plugins/vite-openapi-plugin.ts +71 -0
- package/tsconfig.app.json +22 -0
- package/tsconfig.json +14 -0
- package/tsconfig.node.json +9 -0
- package/tsconfig.vite-plugins.json +10 -0
- package/tsconfig.vitest.json +9 -0
- package/vite.config.js +37 -35
- package/vitest.config.js +17 -0
- package/.eslintrc.js +0 -16
- package/CHANGES.md +0 -2
- package/dist/vue-foundation.cjs.js +0 -5
- package/dist/vue-foundation.umd.js +0 -6
- package/postcss.config.cjs +0 -5
- package/src/app.js +0 -25
- package/src/components/alert.vue +0 -130
- package/src/components/index.js +0 -12
- package/src/config.js +0 -11
- package/src/directives/autofocus.js +0 -17
- package/src/directives/confirm-button.js +0 -40
- package/src/directives/date-input.js +0 -18
- package/src/directives/datetime.js +0 -46
- package/src/directives/disabled.js +0 -28
- package/src/directives/duration.js +0 -72
- package/src/directives/index.js +0 -10
- package/src/directives/infinite-scroll.js +0 -17
- package/src/directives/readonly.js +0 -17
- package/src/directives/tooltip.js +0 -178
- package/src/directives/user-text.js +0 -11
- package/src/filters/index.js +0 -82
- package/src/helpers/array.js +0 -99
- package/src/helpers/context-menu.js +0 -66
- package/src/helpers/delay.js +0 -3
- package/src/helpers/error.js +0 -36
- package/src/helpers/http.js +0 -44
- package/src/helpers/index.js +0 -9
- package/src/helpers/mask.js +0 -90
- package/src/helpers/number.js +0 -6
- package/src/helpers/string.js +0 -36
- package/src/helpers/vue.js +0 -5
- package/src/index.js +0 -33
- package/src/plugins/index.js +0 -10
- package/src/plugins/infinite-scroll/hook.js +0 -30
- package/src/plugins/infinite-scroll.js +0 -100
- package/src/plugins/resize-watcher.js +0 -28
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import $ from 'jquery';
|
|
2
|
-
|
|
3
|
-
import app from '../app';
|
|
4
|
-
|
|
5
|
-
app.config.globalProperties.$contextMenu = function (e, config) {
|
|
6
|
-
var $wrapper = $('<div class="vf-overlay">').click(_closeMenu).appendTo(document.body);
|
|
7
|
-
var $menu = $('<div class="vf-context-menu">').css('position', 'absolute').appendTo($wrapper);
|
|
8
|
-
|
|
9
|
-
var $target = $(e.currentTarget);
|
|
10
|
-
$target.css('user-select', 'none');
|
|
11
|
-
|
|
12
|
-
$target.addClass('context-menu-active');
|
|
13
|
-
|
|
14
|
-
config.targetClass && $target.addClass(config.targetClass);
|
|
15
|
-
config.class && $menu.addClass(config.class);
|
|
16
|
-
|
|
17
|
-
config.items &&
|
|
18
|
-
config.items.forEach(item => {
|
|
19
|
-
if (item == '-') return $('<div class="separator">').appendTo($menu);
|
|
20
|
-
var $item = $('<div class="item">').css('user-select', 'none').text(item.title).appendTo($menu);
|
|
21
|
-
item.class && $item.addClass(item.class);
|
|
22
|
-
if (item.shouldConfirm) $item.data('handler', item.handler).click(_confirmAction);
|
|
23
|
-
else if (item.handler) $item.click(item.handler);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const dx = window.innerWidth - e.clientX;
|
|
27
|
-
const dy = window.innerHeight - e.clientY;
|
|
28
|
-
const menuHeight = $menu.outerHeight();
|
|
29
|
-
const menuWidth = $menu.outerWidth();
|
|
30
|
-
|
|
31
|
-
const left = dx < menuWidth ? e.clientX - menuWidth - 1 : e.clientX + 1;
|
|
32
|
-
const top = dy < menuHeight ? e.clientY - menuHeight - 1 : e.clientY + 1;
|
|
33
|
-
|
|
34
|
-
$menu.css('left', left + 'px');
|
|
35
|
-
$menu.css('top', top + 'px');
|
|
36
|
-
|
|
37
|
-
config.onCreate && config.onCreate($menu[0]);
|
|
38
|
-
|
|
39
|
-
setTimeout(() => {
|
|
40
|
-
$menu.css('width', $menu.outerWidth() + 'px');
|
|
41
|
-
}, 50);
|
|
42
|
-
|
|
43
|
-
function _closeMenu() {
|
|
44
|
-
config.targetClass && $target.removeClass(config.targetClass);
|
|
45
|
-
$target.removeClass('context-menu-active');
|
|
46
|
-
$target.css('user-select', '');
|
|
47
|
-
$wrapper.remove();
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _confirmAction(e) {
|
|
51
|
-
var $item = $(e.currentTarget);
|
|
52
|
-
if ($item.hasClass('pending-confirm')) {
|
|
53
|
-
var handler = $item.data('handler');
|
|
54
|
-
handler && handler();
|
|
55
|
-
} else {
|
|
56
|
-
var originalContent = $item.html();
|
|
57
|
-
$item.addClass('pending-confirm').text('Confirm');
|
|
58
|
-
$item.one('mouseleave', function () {
|
|
59
|
-
$item.removeClass('pending-confirm').html(originalContent);
|
|
60
|
-
});
|
|
61
|
-
e.stopPropagation();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// TODO: actually de-select text rather than just using CSS to hide its selection
|
package/src/helpers/delay.js
DELETED
package/src/helpers/error.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import app from '../app';
|
|
2
|
-
import vfConfig from '../config';
|
|
3
|
-
|
|
4
|
-
app.config.globalProperties.$reportError = err => {
|
|
5
|
-
if (!(err instanceof Error)) {
|
|
6
|
-
err = new Error(err);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if (vfConfig.reportErrorHandler) {
|
|
10
|
-
vfConfig.reportErrorHandler(err);
|
|
11
|
-
} else {
|
|
12
|
-
console.error(err);
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
app.config.globalProperties.$throwUserError = msg => {
|
|
17
|
-
let err = new Error(msg);
|
|
18
|
-
err.code = 'USERERR';
|
|
19
|
-
throw err;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
Object.defineProperty(Error.prototype, 'userMessage', {
|
|
23
|
-
get() {
|
|
24
|
-
if (this.code == 'USERERR') return this.message;
|
|
25
|
-
else
|
|
26
|
-
return `An application error has occurred:\n\n${this.message}\n\nPlease refresh the page and try again. If this error persists, ${vfConfig.unhandledErrorSupportText}.`;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
Error.prototype.handle = function () {
|
|
31
|
-
if (this.code != 'USERERR') {
|
|
32
|
-
app.config.globalProperties.$reportError(this);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return this;
|
|
36
|
-
};
|
package/src/helpers/http.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
|
|
3
|
-
import app from '../app';
|
|
4
|
-
app.config.globalProperties.$http = axios;
|
|
5
|
-
|
|
6
|
-
axios.postOrPut = (baseUrl, id, ...args) => {
|
|
7
|
-
const method = id ? 'put' : 'post';
|
|
8
|
-
const url = id ? `${baseUrl}/${id}` : baseUrl;
|
|
9
|
-
return axios[method](url, ...args);
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
import vfConfig from '../config';
|
|
13
|
-
|
|
14
|
-
axios.interceptors.response.use(
|
|
15
|
-
response => {
|
|
16
|
-
// TODO: will Axios auto-reject non-JSON?
|
|
17
|
-
if (response.data && typeof response.data != 'object') {
|
|
18
|
-
throw new Error('response was not JSON');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return response;
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
err => {
|
|
25
|
-
if (err.response && err.response.status == 401) {
|
|
26
|
-
if (vfConfig.unauthorizedHttpResponseHandler) {
|
|
27
|
-
const result = vfConfig.unauthorizedHttpResponseHandler(err.response);
|
|
28
|
-
|
|
29
|
-
// if the handler said "ok, handled", then we're going to
|
|
30
|
-
// return a promise that never resolves to prevent the userland code
|
|
31
|
-
// from ever proceeding
|
|
32
|
-
if (result) return new Promise(() => {});
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (err.response && err.response.data && err.response.data.error) {
|
|
37
|
-
err.code = err.response.status == 422 ? 'USERERR' : 'APIERR';
|
|
38
|
-
err.message = err.response.data.error;
|
|
39
|
-
err.field = err.response.data.errorField;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
throw err;
|
|
43
|
-
}
|
|
44
|
-
);
|
package/src/helpers/index.js
DELETED
package/src/helpers/mask.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import $ from 'jquery';
|
|
2
|
-
|
|
3
|
-
import app from '../app';
|
|
4
|
-
|
|
5
|
-
/*///////////////////////////////////////////////
|
|
6
|
-
Masking
|
|
7
|
-
//////////////////////////////////////////////*/
|
|
8
|
-
app.config.globalProperties.$mask = function (message) {
|
|
9
|
-
let $el = $(this.$el);
|
|
10
|
-
this.$maskEl($el.hasClass('vf-overlay') ? $el.find('.vf-modal')[0] : this.$el, message);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
app.config.globalProperties.$maskEl = function (el, message) {
|
|
14
|
-
if (this._currentMask) return;
|
|
15
|
-
this._currentMask = $('<div class="mask">')
|
|
16
|
-
.text(message || 'Please wait...')
|
|
17
|
-
.appendTo(el);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
app.config.globalProperties.$unmask = function () {
|
|
21
|
-
if (!this._currentMask) return;
|
|
22
|
-
$(this._currentMask).remove();
|
|
23
|
-
delete this._currentMask;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
app.config.globalProperties.$maskForm = function (waitButton, waitText) {
|
|
27
|
-
let el = this.$el;
|
|
28
|
-
|
|
29
|
-
if (waitButton !== undefined && waitButton.tagName == 'FORM') {
|
|
30
|
-
el = waitButton;
|
|
31
|
-
waitButton = undefined;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
let $form = el.tagName == 'FORM' ? $(el) : $(el).find('form');
|
|
35
|
-
let $inputs = $form.find('input, select, textarea, button').not('[disabled]');
|
|
36
|
-
$form.addClass('masked');
|
|
37
|
-
$form.data('vf-masked-inputs', $inputs);
|
|
38
|
-
$inputs.attr('disabled', 'disabled');
|
|
39
|
-
|
|
40
|
-
if (waitButton === undefined) {
|
|
41
|
-
waitButton = $form.find('button:first');
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (waitButton) {
|
|
45
|
-
let $waitButton = $form.find(waitButton);
|
|
46
|
-
$waitButton.disable(waitText || 'Please wait...');
|
|
47
|
-
$form.data('vf-masked-wait-btn', $waitButton);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
app.config.globalProperties.$unmaskForm = function () {
|
|
52
|
-
let $form = this.$el.tagName == 'FORM' ? $(this.$el) : $(this.$el).find('form.masked');
|
|
53
|
-
if (!$form.length) return;
|
|
54
|
-
let $inputs = $form.data('vf-masked-inputs');
|
|
55
|
-
$inputs.removeAttr('disabled');
|
|
56
|
-
$form.removeData('vf-masked-inputs');
|
|
57
|
-
let $waitButton = $form.data('vf-masked-wait-btn');
|
|
58
|
-
if ($waitButton) {
|
|
59
|
-
$form.removeData('vf-masked-wait-btn');
|
|
60
|
-
$waitButton.enable();
|
|
61
|
-
}
|
|
62
|
-
$form.removeClass('masked');
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/*///////////////////////////////////////////////
|
|
66
|
-
Button Enable/Disable
|
|
67
|
-
//////////////////////////////////////////////*/
|
|
68
|
-
$.fn.disable = function (newText) {
|
|
69
|
-
this.each(function (index, item) {
|
|
70
|
-
var $item = $(item);
|
|
71
|
-
var isInput = item.tagName == 'INPUT';
|
|
72
|
-
newText &&
|
|
73
|
-
$item.data('originalValue', isInput ? $item.val() : $item.html()) &&
|
|
74
|
-
$item[isInput ? 'val' : 'text'](newText);
|
|
75
|
-
$item.attr('disabled', 'disabled');
|
|
76
|
-
});
|
|
77
|
-
return this;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
$.fn.enable = function () {
|
|
81
|
-
this.each(function (index, item) {
|
|
82
|
-
var $item = $(item);
|
|
83
|
-
$item.removeAttr('disabled');
|
|
84
|
-
var originalValue = $item.data('originalValue');
|
|
85
|
-
originalValue != undefined &&
|
|
86
|
-
$item[item.tagName == 'INPUT' ? 'val' : 'html'](originalValue) &&
|
|
87
|
-
$item.removeData('originalValue');
|
|
88
|
-
});
|
|
89
|
-
return this;
|
|
90
|
-
};
|
package/src/helpers/number.js
DELETED
package/src/helpers/string.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
String.prototype.escapeHtml = function () {
|
|
2
|
-
return this.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
String.prototype.nl2br = function () {
|
|
6
|
-
return this.replace(/\n/g, '<br>');
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
// this isn't implemented in Vue filters because why would you ever turn something _into_ kebab case for user display?
|
|
10
|
-
String.prototype.kebab = function () {
|
|
11
|
-
return this.replace(/ /g, '-');
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// TODO: what would this be used for?
|
|
15
|
-
String.prototype.lcfirst = function () {
|
|
16
|
-
return this.substr(0, 1).toLowerCase() + this.substr(1);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// this isn't implemented in Vue filters because why would you ever turn something _into_ Snake case for user display?
|
|
20
|
-
String.prototype.snake = function () {
|
|
21
|
-
return this.replace(/ /g, '_');
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
String.prototype.ucfirst = function () {
|
|
25
|
-
return this.substr(0, 1).toUpperCase() + this.substr(1);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
String.prototype.ucwords = function () {
|
|
29
|
-
return this.replace(/^[a-z]| [a-z]/gi, function (value) {
|
|
30
|
-
return value.toUpperCase();
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
String.prototype.unsnake = function () {
|
|
35
|
-
return this.replace(/_/g, ' ');
|
|
36
|
-
};
|
package/src/helpers/vue.js
DELETED
package/src/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// REMINDER: if there is a node_modules folder here during development of another app linking to this dev build,
|
|
2
|
-
// the 'Vue' imports here will _not_ be the same as the 'Vue' imports from the app due to absolute path differences
|
|
3
|
-
// thus, nothing that's attached to Vue here will be attached to Vue there, and everything will be broken
|
|
4
|
-
|
|
5
|
-
import './components';
|
|
6
|
-
import './directives';
|
|
7
|
-
import './helpers';
|
|
8
|
-
import './plugins';
|
|
9
|
-
|
|
10
|
-
import app, { setRootComponent } from './app';
|
|
11
|
-
import vfConfig from './config';
|
|
12
|
-
import { registerFilter, registerFilters } from './filters';
|
|
13
|
-
|
|
14
|
-
export default {
|
|
15
|
-
getApp,
|
|
16
|
-
configure,
|
|
17
|
-
mount,
|
|
18
|
-
registerFilter,
|
|
19
|
-
registerFilters
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
function configure(options) {
|
|
23
|
-
vfConfig.set(options);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function mount(rootComponent, target) {
|
|
27
|
-
setRootComponent(rootComponent);
|
|
28
|
-
app.vm = app.mount(target);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function getApp() {
|
|
32
|
-
return app;
|
|
33
|
-
}
|
package/src/plugins/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// TODO: switch to intersection observer
|
|
2
|
-
|
|
3
|
-
export default class InfiniteScrollHook {
|
|
4
|
-
constructor(el, handler) {
|
|
5
|
-
this.el = el;
|
|
6
|
-
this.handler = handler;
|
|
7
|
-
|
|
8
|
-
this.isTripped = false;
|
|
9
|
-
this.onScroll = this._onScroll.bind(this);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
install() {
|
|
13
|
-
this.el.addEventListener('scroll', this.onScroll);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
uninstall() {
|
|
17
|
-
this.el.removeEventListener('scroll', this.onScroll);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
_onScroll(e) {
|
|
21
|
-
if (Math.ceil(this.el.scrollTop + this.el.clientHeight + 5) >= this.el.scrollHeight) {
|
|
22
|
-
if (!this.isTripped) {
|
|
23
|
-
this.handler(e);
|
|
24
|
-
this.isTripped = true;
|
|
25
|
-
}
|
|
26
|
-
} else if (this.isTripped) {
|
|
27
|
-
this.isTripped = false;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
// TODO: switch to intersection observer
|
|
2
|
-
|
|
3
|
-
import InfiniteScrollHook from './infinite-scroll/hook';
|
|
4
|
-
|
|
5
|
-
class InfiniteScroll {
|
|
6
|
-
static install(app) {
|
|
7
|
-
const scrollableValues = ['auto', 'scroll'];
|
|
8
|
-
const discoverScrollableAncestorEl = function (el) {
|
|
9
|
-
el = el.parentElement;
|
|
10
|
-
if (!el) return null;
|
|
11
|
-
|
|
12
|
-
const computedStyle = window.getComputedStyle(el);
|
|
13
|
-
if (
|
|
14
|
-
scrollableValues.includes(computedStyle.overflow) ||
|
|
15
|
-
scrollableValues.includes(computedStyle.overflowX) ||
|
|
16
|
-
scrollableValues.includes(computedStyle.overflowY)
|
|
17
|
-
) {
|
|
18
|
-
return el;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return discoverScrollableAncestorEl(el);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const installScrollHook = function () {
|
|
25
|
-
if (this.$options.windowScrolledToBottom) {
|
|
26
|
-
this._windowScrollHook = new InfiniteScrollHook(
|
|
27
|
-
window,
|
|
28
|
-
this.$options.windowScrolledToBottom.bind(this)
|
|
29
|
-
);
|
|
30
|
-
this._windowScrollHook.install();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (this.$options.elScrolledToBottom) {
|
|
34
|
-
this._elScrollHook = new InfiniteScrollHook(this.$el, this.$options.elScrolledToBottom.bind(this));
|
|
35
|
-
this._elScrollHook.install();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (this.$options.ancestorScrolledToBottom) {
|
|
39
|
-
const scrollableAncestorEl = discoverScrollableAncestorEl(this.$el);
|
|
40
|
-
if (scrollableAncestorEl) {
|
|
41
|
-
this._ancestorScrollHook = new InfiniteScrollHook(
|
|
42
|
-
scrollableAncestorEl,
|
|
43
|
-
this.$options.ancestorScrolledToBottom.bind(this)
|
|
44
|
-
);
|
|
45
|
-
this._ancestorScrollHook.install();
|
|
46
|
-
} else {
|
|
47
|
-
console.warn('no scollable ancestor found for component:', this);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const reinstallScrollHook = function () {
|
|
53
|
-
if (this._windowScrollHandler) {
|
|
54
|
-
this._windowScrollHandler.install();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (this._elScrollHandler) {
|
|
58
|
-
this._elScrollHandler.install();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (this._ancestorScrollHook) {
|
|
62
|
-
this._ancestorScrollHook.install();
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
const removeScrollHook = function () {
|
|
67
|
-
if (this._windowScrollHandler) {
|
|
68
|
-
this._windowScrollHandler.uninstall();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (this._elScrollHandler) {
|
|
72
|
-
this._elScrollHandler.uninstall();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
if (this._ancestorScrollHook) {
|
|
76
|
-
this._ancestorScrollHook.uninstall();
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
app.mixin({
|
|
81
|
-
mounted() {
|
|
82
|
-
installScrollHook.call(this);
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
activated() {
|
|
86
|
-
reinstallScrollHook.call(this);
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
deactivated() {
|
|
90
|
-
removeScrollHook.call(this);
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
beforeUnmount() {
|
|
94
|
-
removeScrollHook.call(this);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export default InfiniteScroll;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// TODO: find out if we can use the Vue options array for the functions instead of making them part of "methods"
|
|
2
|
-
|
|
3
|
-
class ResizeWatcher {
|
|
4
|
-
static install(app) {
|
|
5
|
-
app.mixin({
|
|
6
|
-
mounted() {
|
|
7
|
-
if (this.$options.windowResized) {
|
|
8
|
-
this._resizeWatcherHandler = this.$options.windowResized.bind(this);
|
|
9
|
-
window.addEventListener('resize', this._resizeWatcherHandler);
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
activated() {
|
|
14
|
-
this._resizeWatcherHandler && window.addEventListener('resize', this._resizeWatcherHandler);
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
deactivated() {
|
|
18
|
-
this._resizeWatcherHandler && window.removeEventListener('resize', this._resizeWatcherHandler);
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
beforeUnmount() {
|
|
22
|
-
this._resizeWatcherHandler && window.removeEventListener('resize', this._resizeWatcherHandler);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default ResizeWatcher;
|