@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
package/src/config.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
let options = {
|
|
2
|
-
unhandledErrorSupportText: 'please contact support'
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
function applyConfiguration(inOptions) {
|
|
6
|
-
Object.assign(options, inOptions);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(options, 'set', { value: applyConfiguration, enumerable: false });
|
|
10
|
-
|
|
11
|
-
export default options;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import $ from 'jquery';
|
|
2
|
-
|
|
3
|
-
import app from '../app';
|
|
4
|
-
|
|
5
|
-
app.directive('autofocus', {
|
|
6
|
-
mounted: fn,
|
|
7
|
-
updated: fn
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
function fn(el, binding) {
|
|
11
|
-
if (binding.value === undefined && el.hasAutoFocused) return;
|
|
12
|
-
if (binding.value !== undefined && !binding.value) return;
|
|
13
|
-
if (binding.oldValue !== undefined && binding.value == binding.oldValue) return;
|
|
14
|
-
el.hasAutoFocused = true;
|
|
15
|
-
el = ['BUTTON', 'INPUT', 'TEXTAREA', 'SELECT'].indexOf(el.tagName) > -1 ? el : $(el).find('input:first')[0];
|
|
16
|
-
setTimeout(() => el.focus(), 10);
|
|
17
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import app from '../app';
|
|
2
|
-
|
|
3
|
-
app.directive('confirm-button', {
|
|
4
|
-
mounted(el) {
|
|
5
|
-
el.addEventListener('click', e => {
|
|
6
|
-
let now = Date.now();
|
|
7
|
-
|
|
8
|
-
if (el._isConfirming) {
|
|
9
|
-
if (now - el._confirmInitTime < 300) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
el._resetHandler();
|
|
14
|
-
el.dispatchEvent(new Event('confirm'));
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
e.preventDefault();
|
|
19
|
-
e.stopImmediatePropagation();
|
|
20
|
-
|
|
21
|
-
el._resetHandler = () => {
|
|
22
|
-
el.innerHTML = el._preConfirmHTML;
|
|
23
|
-
el.blur();
|
|
24
|
-
|
|
25
|
-
el.removeEventListener('mouseout', el._resetHandler);
|
|
26
|
-
|
|
27
|
-
delete el._isConfirming;
|
|
28
|
-
delete el._preConfirmHTML;
|
|
29
|
-
delete el._resetHandler;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
el._isConfirming = true;
|
|
33
|
-
el._confirmInitTime = now;
|
|
34
|
-
el._preConfirmHTML = el.innerHTML;
|
|
35
|
-
el.innerHTML = 'Confirm';
|
|
36
|
-
|
|
37
|
-
el.addEventListener('mouseout', el._resetHandler);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
|
-
|
|
3
|
-
import app from '../app';
|
|
4
|
-
|
|
5
|
-
app.directive('date-input', {
|
|
6
|
-
beforeMount: fn
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
function fn(el) {
|
|
10
|
-
el.addEventListener('blur', () => {
|
|
11
|
-
let val = el.value;
|
|
12
|
-
if (/^[0-9]{1,2}\/[0-9]{1,2}$/.test(val)) val += '/' + moment().format('YY');
|
|
13
|
-
let ts = Date.parse(val);
|
|
14
|
-
if (isNaN(ts)) el.value = '';
|
|
15
|
-
else el.value = moment(ts).format('MM/DD/YYYY');
|
|
16
|
-
el.dispatchEvent(new Event('input'));
|
|
17
|
-
});
|
|
18
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
|
-
|
|
3
|
-
import app from '../app';
|
|
4
|
-
|
|
5
|
-
app.directive('datetime', {
|
|
6
|
-
beforeMount: applyDateTime,
|
|
7
|
-
updated: applyDateTime
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
function applyDateTime(el, binding) {
|
|
11
|
-
if (binding.value == binding.oldValue && el.innerHTML.length) return;
|
|
12
|
-
el.innerText = getDateTimeValue(el, binding);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function getDateTimeValue(el, binding) {
|
|
16
|
-
if (!binding.value) {
|
|
17
|
-
return el.attributes.placeholder ? el.attributes.placeholder.value : '';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
let prefix = '';
|
|
21
|
-
let thatMoment = el.attributes.local ? moment(binding.value) : moment.utc(binding.value);
|
|
22
|
-
|
|
23
|
-
if (!el.attributes['display-utc']) thatMoment.local();
|
|
24
|
-
|
|
25
|
-
let format = el.attributes.format ? el.attributes.format.value : null;
|
|
26
|
-
|
|
27
|
-
if (!format && el.attributes['relative-date']) {
|
|
28
|
-
let thisMoment = moment();
|
|
29
|
-
if (
|
|
30
|
-
thisMoment.year() == thatMoment.year() &&
|
|
31
|
-
thisMoment.month() == thatMoment.month() &&
|
|
32
|
-
thisMoment.date() == thatMoment.date()
|
|
33
|
-
) {
|
|
34
|
-
prefix = 'at';
|
|
35
|
-
format = 'HH:mm';
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (!format) format = 'MM/DD/YY HH:mm';
|
|
40
|
-
|
|
41
|
-
let result = thatMoment.format(format);
|
|
42
|
-
|
|
43
|
-
if (prefix) result = prefix + ' ' + result;
|
|
44
|
-
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import $ from 'jquery';
|
|
2
|
-
|
|
3
|
-
import app from '../app';
|
|
4
|
-
|
|
5
|
-
app.directive('disabled', {
|
|
6
|
-
beforeMount: fn,
|
|
7
|
-
updated: fn,
|
|
8
|
-
unmounted
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
function fn(el, binding) {
|
|
12
|
-
if (el.tagName == 'LABEL') {
|
|
13
|
-
$(el).toggleClass('disabled', !!binding.value);
|
|
14
|
-
el = $(el).find('input')[0];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (binding.value) $(el).attr('disabled', 'disabled');
|
|
18
|
-
else $(el).removeAttr('disabled');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function unmounted(el) {
|
|
22
|
-
if (el.tagName == 'LABEL') {
|
|
23
|
-
$(el).removeClass('disabled');
|
|
24
|
-
el = $(el).find('input')[0];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
$(el).removeAttr('disabled');
|
|
28
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
|
-
|
|
3
|
-
import app from '../app';
|
|
4
|
-
|
|
5
|
-
let durationEls = [];
|
|
6
|
-
|
|
7
|
-
function updateDurations() {
|
|
8
|
-
durationEls.forEach(updateDuration);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
setInterval(updateDurations, 1000);
|
|
12
|
-
|
|
13
|
-
app.directive('duration', {
|
|
14
|
-
beforeMount: applyDuration,
|
|
15
|
-
updated: applyDuration,
|
|
16
|
-
unmounted: removeDuration
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
function applyDuration(el, binding) {
|
|
20
|
-
if (binding.value == binding.oldValue) return;
|
|
21
|
-
if (!binding.value) return removeDuration(el);
|
|
22
|
-
|
|
23
|
-
el.$includeSeconds = typeof el.attributes['no-seconds'] === 'undefined';
|
|
24
|
-
|
|
25
|
-
let baseTimeAttr = el.attributes['base-time'];
|
|
26
|
-
if (baseTimeAttr) {
|
|
27
|
-
el.$startTs = moment(baseTimeAttr.value).valueOf() - binding.value * 1000;
|
|
28
|
-
} else {
|
|
29
|
-
el.$startTs = moment(binding.value).valueOf();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!el.$isConfigured) {
|
|
33
|
-
el.$isConfigured = true;
|
|
34
|
-
durationEls.push(el);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
updateDuration(el);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function updateDuration(el) {
|
|
41
|
-
let ts = el.$startTs;
|
|
42
|
-
let diff = Math.round((Date.now() - ts) / 1000);
|
|
43
|
-
el.innerText = secondsToString(diff, el.$includeSeconds === false);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function removeDuration(el) {
|
|
47
|
-
if (el.$isConfigured) {
|
|
48
|
-
durationEls.remove(el);
|
|
49
|
-
el.$isConfigured = false;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
el.innerText = '-';
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function secondsToString(seconds, shouldSkipSeconds) {
|
|
56
|
-
let result = [];
|
|
57
|
-
let days = Math.floor(seconds / 86400);
|
|
58
|
-
days && result.push(days + 'd');
|
|
59
|
-
seconds -= days * 86400;
|
|
60
|
-
let hours = Math.floor(seconds / 3600);
|
|
61
|
-
(days || hours) && result.push(hours + 'h');
|
|
62
|
-
seconds -= hours * 3600;
|
|
63
|
-
let minutes = Math.floor(seconds / 60);
|
|
64
|
-
(days || hours || minutes) && result.push(minutes + 'm');
|
|
65
|
-
if (!shouldSkipSeconds) {
|
|
66
|
-
seconds -= minutes * 60;
|
|
67
|
-
result.push(seconds + 's');
|
|
68
|
-
} else if (!result.length) {
|
|
69
|
-
result.push('0m');
|
|
70
|
-
}
|
|
71
|
-
return result.join(' ');
|
|
72
|
-
}
|
package/src/directives/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import app from '../app';
|
|
2
|
-
import InfiniteScrollHook from '../plugins/infinite-scroll/hook';
|
|
3
|
-
|
|
4
|
-
app.directive('infinite-scroll', {
|
|
5
|
-
beforeMount(el, binding) {
|
|
6
|
-
if (binding.value) {
|
|
7
|
-
el._infiniteScrollHook = new InfiniteScrollHook(el, binding.value);
|
|
8
|
-
el._infiniteScrollHook.install();
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
unmounted(el) {
|
|
13
|
-
if (el._infiniteScrollHook) {
|
|
14
|
-
el._infiniteScrollHook.uninstall();
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import $ from 'jquery';
|
|
2
|
-
|
|
3
|
-
import app from '../app';
|
|
4
|
-
|
|
5
|
-
app.directive('readonly', {
|
|
6
|
-
beforeMount: fn,
|
|
7
|
-
updated: fn
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
function fn(el, binding) {
|
|
11
|
-
if (el.tagName == 'LABEL') {
|
|
12
|
-
el = $(el).find('input')[0];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (binding.value) $(el).attr('readonly', 'readonly');
|
|
16
|
-
else $(el).removeAttr('readonly');
|
|
17
|
-
}
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
import $ from 'jquery';
|
|
2
|
-
|
|
3
|
-
import app from '../app';
|
|
4
|
-
|
|
5
|
-
app.directive('tip', {
|
|
6
|
-
mounted: createTip,
|
|
7
|
-
updated: createTip,
|
|
8
|
-
unmounted: destroyTip
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
function createTip(el, binding) {
|
|
12
|
-
let tipText = el.attributes.tip ? el.attributes.tip.value : binding.value;
|
|
13
|
-
if (binding.value === false) tipText = null;
|
|
14
|
-
if (tipText) {
|
|
15
|
-
let config = {};
|
|
16
|
-
config[binding.modifiers.html ? 'html' : 'text'] = tipText;
|
|
17
|
-
if (el.attributes['tip-class']) config.class = el.attributes['tip-class'].value;
|
|
18
|
-
$(el).vfTooltip(config);
|
|
19
|
-
} else $(el).vfTooltip('destroy');
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function destroyTip(el) {
|
|
23
|
-
$(el).vfTooltip('destroy');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
$.fn.vfTooltip = function (option) {
|
|
27
|
-
return this.each(function (index, el) {
|
|
28
|
-
var tooltip = $(el).data('vf-tooltip');
|
|
29
|
-
|
|
30
|
-
if (typeof option == 'string') {
|
|
31
|
-
if (!tooltip) return;
|
|
32
|
-
tooltip[option]();
|
|
33
|
-
} else if (tooltip) {
|
|
34
|
-
tooltip.configure(option);
|
|
35
|
-
} else {
|
|
36
|
-
var vfTooltip = new VfTooltip(el, option);
|
|
37
|
-
$(el).data('vf-tooltip', vfTooltip);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
function VfTooltip(el, configIn) {
|
|
43
|
-
// exports
|
|
44
|
-
this.configure = _configure;
|
|
45
|
-
this.destroy = _destroy;
|
|
46
|
-
|
|
47
|
-
// state
|
|
48
|
-
var $tip,
|
|
49
|
-
config,
|
|
50
|
-
lastMoveEvt,
|
|
51
|
-
checkInterval,
|
|
52
|
-
shouldShow = false;
|
|
53
|
-
|
|
54
|
-
// apply config
|
|
55
|
-
this.configure(configIn);
|
|
56
|
-
|
|
57
|
-
var $target = $(el);
|
|
58
|
-
$target.on('mouseenter', _handleTargetMouseEnter);
|
|
59
|
-
$target.on('mouseleave', _handleTargetMouseLeave);
|
|
60
|
-
|
|
61
|
-
config.now && _handleTargetMouseEnter(config.now);
|
|
62
|
-
|
|
63
|
-
function _configure(configIn) {
|
|
64
|
-
config = $.extend(
|
|
65
|
-
{
|
|
66
|
-
delay: 0
|
|
67
|
-
},
|
|
68
|
-
configIn
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function _handleTargetMouseEnter(e) {
|
|
73
|
-
if (shouldShow) return;
|
|
74
|
-
|
|
75
|
-
shouldShow = true;
|
|
76
|
-
|
|
77
|
-
setTimeout(function () {
|
|
78
|
-
if (!shouldShow) return;
|
|
79
|
-
|
|
80
|
-
_renderTooltip();
|
|
81
|
-
|
|
82
|
-
if (config.static) _placeStaticTooltip();
|
|
83
|
-
else _handleMouseMove(e);
|
|
84
|
-
|
|
85
|
-
$tip.show();
|
|
86
|
-
}, config.delay);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function _handleTargetMouseLeave() {
|
|
90
|
-
shouldShow = false;
|
|
91
|
-
_deferredRemoveTooltip();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function _renderTooltip() {
|
|
95
|
-
if (!$tip) config.static || $(window).on('mousemove', _handleMouseMove);
|
|
96
|
-
else $tip.remove();
|
|
97
|
-
|
|
98
|
-
$tip = $('<div class="vf-tooltip">')
|
|
99
|
-
.css('position', 'absolute')
|
|
100
|
-
.css('z-index', '1000000')
|
|
101
|
-
.addClass(config.class)
|
|
102
|
-
.appendTo(document.body);
|
|
103
|
-
config.title && $('<div class="title">').text(config.title).appendTo($tip);
|
|
104
|
-
var $content = $('<div class="content">').appendTo($tip);
|
|
105
|
-
|
|
106
|
-
if (config.callback) config.callback($content[0]);
|
|
107
|
-
else if (config.text) $content.text(config.text).html($content.html().replace(/\n/g, '<br>'));
|
|
108
|
-
else if (config.html) $content.html(config.html);
|
|
109
|
-
|
|
110
|
-
if (config.static) {
|
|
111
|
-
$tip.mouseover(function () {
|
|
112
|
-
shouldShow = true;
|
|
113
|
-
}).mouseout(function () {
|
|
114
|
-
shouldShow = false;
|
|
115
|
-
_deferredRemoveTooltip();
|
|
116
|
-
});
|
|
117
|
-
} else {
|
|
118
|
-
checkInterval = setInterval(_checkMoveEvent, 250);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function _deferredRemoveTooltip() {
|
|
123
|
-
if (config.static) setTimeout(_removeTooltip, 50);
|
|
124
|
-
else _removeTooltip();
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function _removeTooltip() {
|
|
128
|
-
if (shouldShow) return;
|
|
129
|
-
if (!$tip) return;
|
|
130
|
-
|
|
131
|
-
$tip.remove();
|
|
132
|
-
$tip = null;
|
|
133
|
-
|
|
134
|
-
clearInterval(checkInterval);
|
|
135
|
-
|
|
136
|
-
config.static || $(window).off('mousemove', _handleMouseMove);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function _placeStaticTooltip() {
|
|
140
|
-
var targetPosition = $target.position();
|
|
141
|
-
var tipHeight = $tip.height();
|
|
142
|
-
var tipW = $target.outerWidth(true);
|
|
143
|
-
var tipX = targetPosition.left;
|
|
144
|
-
var tipY = targetPosition.top - tipHeight - 1;
|
|
145
|
-
if (tipY - 2 < 0) tipY = targetPosition.top + $target.outerHeight(true) + 1;
|
|
146
|
-
$tip.css('min-width', tipW + 'px')
|
|
147
|
-
.css('left', tipX + 'px')
|
|
148
|
-
.css('top', tipY + 'px');
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
function _handleMouseMove(e) {
|
|
152
|
-
var tipWidth = $tip.outerWidth(),
|
|
153
|
-
tipHeight = $tip.outerHeight();
|
|
154
|
-
var viewWidth = window.innerWidth,
|
|
155
|
-
viewHeight = window.innerHeight;
|
|
156
|
-
var tipX = e.pageX + 10,
|
|
157
|
-
tipY = e.pageY + 20;
|
|
158
|
-
if (tipX + tipWidth > viewWidth) tipX = e.pageX - 5 - tipWidth;
|
|
159
|
-
if (tipY + tipHeight > viewHeight) tipY = e.pageY - 5 - tipHeight;
|
|
160
|
-
$tip.css('left', tipX + 'px').css('top', tipY + 'px');
|
|
161
|
-
lastMoveEvt = e;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function _checkMoveEvent() {
|
|
165
|
-
if (!lastMoveEvt) return;
|
|
166
|
-
if (el != lastMoveEvt.target && !$.contains(el, lastMoveEvt.target)) _handleTargetMouseLeave();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function _destroy() {
|
|
170
|
-
shouldShow = false;
|
|
171
|
-
|
|
172
|
-
_removeTooltip();
|
|
173
|
-
|
|
174
|
-
$target.off('mouseenter', _handleTargetMouseEnter);
|
|
175
|
-
$target.off('mouseleave', _handleTargetMouseLeave);
|
|
176
|
-
$target.removeData('vf-tooltip');
|
|
177
|
-
}
|
|
178
|
-
}
|
package/src/filters/index.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import app from '../app';
|
|
2
|
-
|
|
3
|
-
const filterFns = {
|
|
4
|
-
bytes(value) {
|
|
5
|
-
var i = Math.floor(Math.log(value) / Math.log(1024));
|
|
6
|
-
return (value / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'KB', 'MB', 'GB', 'TB'][i];
|
|
7
|
-
},
|
|
8
|
-
|
|
9
|
-
dash(value) {
|
|
10
|
-
return value !== null && value !== undefined && String(value).length ? value : '-';
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
dashZeros(value) {
|
|
14
|
-
return value ? value : '-';
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
grammarcase(value) {
|
|
18
|
-
return value ? value.grammarcase() : null;
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
lowercase(value) {
|
|
22
|
-
return value ? value.toLowerCase() : null;
|
|
23
|
-
},
|
|
24
|
-
|
|
25
|
-
number(value) {
|
|
26
|
-
if (value === null || !/^[0-9]+$/.test(value)) return value;
|
|
27
|
-
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
phone(value) {
|
|
31
|
-
if (!value) return value;
|
|
32
|
-
let cleanValue = value.replace(/[^0-9]/g, '').replace(/^1/, '');
|
|
33
|
-
if (cleanValue.length != 10) return value;
|
|
34
|
-
return '(' + cleanValue.substr(0, 3) + ') ' + cleanValue.substr(3, 3) + '-' + cleanValue.substr(6);
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
ucfirst(value) {
|
|
38
|
-
return value ? value.ucfirst() : null;
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
ucwords(value) {
|
|
42
|
-
return value ? value.ucwords() : null;
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
uppercase(value) {
|
|
46
|
-
return value ? value.toUpperCase() : null;
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
unsnake(value) {
|
|
50
|
-
return value ? value.unsnake() : null;
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
usCurrency(value) {
|
|
54
|
-
return (
|
|
55
|
-
'$' +
|
|
56
|
-
Number(value)
|
|
57
|
-
.toFixed(3)
|
|
58
|
-
.replace(/0$/, '')
|
|
59
|
-
.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
function registerFilters(filters) {
|
|
65
|
-
for (let filterName of Object.keys(filters)) {
|
|
66
|
-
registerFilter(filterName, filters[filterName]);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function registerFilter(name, fn) {
|
|
71
|
-
filterFns[name] = fn;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
app.config.globalProperties.$filter = (value, ...filters) => {
|
|
75
|
-
for (let filter of filters) {
|
|
76
|
-
value = filterFns[filter](value);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return value;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export { registerFilter, registerFilters };
|
package/src/helpers/array.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(Array.prototype, 'diff', {
|
|
2
|
-
enumerable: false,
|
|
3
|
-
value: function (...args) {
|
|
4
|
-
return this.filter(val => {
|
|
5
|
-
for (let i = 0; i < args.length; i++) {
|
|
6
|
-
if (args[i].includes(val)) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return true;
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
Object.defineProperty(Array.prototype, 'first', {
|
|
17
|
-
enumerable: false,
|
|
18
|
-
value: function () {
|
|
19
|
-
return this[0] || undefined;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
Object.defineProperty(Array.prototype, 'intersect', {
|
|
24
|
-
enumerable: false,
|
|
25
|
-
value: function (...args) {
|
|
26
|
-
return this.filter(val => {
|
|
27
|
-
for (let i = 0; i < args.length; i++) {
|
|
28
|
-
if (args[i].includes(val)) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return false;
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
Object.defineProperty(Array.prototype, 'keyBy', {
|
|
39
|
-
enumerable: false,
|
|
40
|
-
value: function (keyProp) {
|
|
41
|
-
let result = {};
|
|
42
|
-
this.forEach(elem => {
|
|
43
|
-
result[elem[keyProp]] = elem;
|
|
44
|
-
});
|
|
45
|
-
return result;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
Object.defineProperty(Array.prototype, 'last', {
|
|
50
|
-
enumerable: false,
|
|
51
|
-
value: function () {
|
|
52
|
-
return this.length ? this[this.length - 1] : undefined;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
Object.defineProperty(Array.prototype, 'pluck', {
|
|
57
|
-
enumerable: false,
|
|
58
|
-
value: function (prop, keyProp) {
|
|
59
|
-
if (typeof keyProp === 'undefined') return this.map(elem => elem[prop]);
|
|
60
|
-
|
|
61
|
-
let result = {};
|
|
62
|
-
this.forEach(elem => {
|
|
63
|
-
result[elem[keyProp]] = elem[prop];
|
|
64
|
-
});
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
Object.defineProperty(Array.prototype, 'remove', {
|
|
70
|
-
enumerable: false,
|
|
71
|
-
value: function (element) {
|
|
72
|
-
const index = this.indexOf(element);
|
|
73
|
-
index > -1 && this.splice(index, 1);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
Object.defineProperty(Array.prototype, 'replace', {
|
|
78
|
-
enumerable: false,
|
|
79
|
-
value: function (element, replacement) {
|
|
80
|
-
const index = this.indexOf(element);
|
|
81
|
-
index > -1 && this.splice(index, 1, replacement);
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
Object.defineProperty(Array.prototype, 'sortBy', {
|
|
86
|
-
enumerable: false,
|
|
87
|
-
value: function (key) {
|
|
88
|
-
this.sort((a, b) => {
|
|
89
|
-
return String(a[key]).toLowerCase().localeCompare(String(b[key]).toLowerCase());
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
Object.defineProperty(Array.prototype, 'unique', {
|
|
95
|
-
enumerable: false,
|
|
96
|
-
value: function () {
|
|
97
|
-
return [...new Set(this)];
|
|
98
|
-
}
|
|
99
|
-
});
|