@signal24/vue-foundation 3.8.0 → 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 -0
- package/dist/vue-foundation.es.js +1129 -0
- 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 -13
- 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/vite.config.js
CHANGED
|
@@ -1,42 +1,44 @@
|
|
|
1
|
-
import { fileURLToPath, URL } from 'node:url'
|
|
2
|
-
|
|
3
|
-
import
|
|
1
|
+
import { fileURLToPath, URL } from 'node:url';
|
|
2
|
+
|
|
3
|
+
import eslintPlugin from '@nabla/vite-plugin-eslint';
|
|
4
|
+
import vue from '@vitejs/plugin-vue';
|
|
4
5
|
import path from 'path';
|
|
6
|
+
import { defineConfig } from 'vite';
|
|
5
7
|
|
|
6
8
|
// https://vitejs.dev/config/
|
|
7
9
|
export default defineConfig({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
rollupOptions: {
|
|
19
|
-
// make sure to externalize deps that should not be bundled
|
|
20
|
-
// into your library
|
|
21
|
-
input: {
|
|
22
|
-
main: path.resolve(__dirname, "src/index.js")
|
|
23
|
-
},
|
|
24
|
-
external: ['axios', 'jquery', 'lodash', 'moment', 'vue-stash-nested', 'vue'],
|
|
25
|
-
output: {
|
|
26
|
-
assetFileNames: (assetInfo) => {
|
|
27
|
-
if (assetInfo.name === 'index.css') return 'vue-foundation.css';
|
|
28
|
-
return assetInfo.name;
|
|
29
|
-
},
|
|
30
|
-
exports: "named",
|
|
31
|
-
globals: {
|
|
32
|
-
vue: 'Vue',
|
|
10
|
+
plugins: [vue(), eslintPlugin()],
|
|
11
|
+
build: {
|
|
12
|
+
cssCodeSplit: true,
|
|
13
|
+
lib: {
|
|
14
|
+
// Could also be a dictionary or array of multiple entry points
|
|
15
|
+
entry: 'src/index.ts',
|
|
16
|
+
name: 'VueFoundatation',
|
|
17
|
+
formats: ['es'],
|
|
18
|
+
fileName: format => `vue-foundation.${format}.js`
|
|
33
19
|
},
|
|
34
|
-
|
|
20
|
+
rollupOptions: {
|
|
21
|
+
// make sure to externalize deps that should not be bundled
|
|
22
|
+
// into your library
|
|
23
|
+
input: {
|
|
24
|
+
main: path.resolve(__dirname, 'src/index.ts')
|
|
25
|
+
},
|
|
26
|
+
external: ['date-fns', 'lodash', 'vue', '@vue/shared'],
|
|
27
|
+
output: {
|
|
28
|
+
assetFileNames: assetInfo => {
|
|
29
|
+
if (assetInfo.name === 'index.css') return 'vue-foundation.css';
|
|
30
|
+
return assetInfo.name;
|
|
31
|
+
},
|
|
32
|
+
exports: 'named',
|
|
33
|
+
globals: {
|
|
34
|
+
vue: 'Vue'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
35
38
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
resolve: {
|
|
40
|
+
alias: {
|
|
41
|
+
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
42
|
+
}
|
|
40
43
|
}
|
|
41
|
-
|
|
42
|
-
})
|
|
44
|
+
});
|
package/vitest.config.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
|
|
3
|
+
import { mergeConfig } from 'vite';
|
|
4
|
+
import { configDefaults, defineConfig } from 'vitest/config';
|
|
5
|
+
|
|
6
|
+
import viteConfig from './vite.config';
|
|
7
|
+
|
|
8
|
+
export default mergeConfig(
|
|
9
|
+
viteConfig,
|
|
10
|
+
defineConfig({
|
|
11
|
+
test: {
|
|
12
|
+
environment: 'jsdom',
|
|
13
|
+
exclude: [...configDefaults.exclude, 'e2e/*'],
|
|
14
|
+
root: fileURLToPath(new URL('./', import.meta.url))
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
);
|
package/.eslintrc.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
env: {
|
|
4
|
-
node: true
|
|
5
|
-
},
|
|
6
|
-
extends: ['plugin:vue/vue3-essential', 'eslint:recommended', '@vue/prettier'],
|
|
7
|
-
rules: {
|
|
8
|
-
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
9
|
-
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
|
10
|
-
'simple-import-sort/imports': 'error',
|
|
11
|
-
'simple-import-sort/exports': 'error',
|
|
12
|
-
'prettier/prettier': 'warn',
|
|
13
|
-
'no-unused-vars': 'warn'
|
|
14
|
-
},
|
|
15
|
-
plugins: ['simple-import-sort']
|
|
16
|
-
};
|
package/CHANGES.md
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
# Release notes
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
|
-
|
|
6
|
-
## 1.0.1
|
|
7
|
-
|
|
8
|
-
- Update dependencies
|
|
9
|
-
- Fix $confirmDestroy
|
|
10
|
-
|
|
11
|
-
## 1.0.0
|
|
12
|
-
|
|
13
|
-
- Initial public release
|
package/postcss.config.cjs
DELETED
package/src/app.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { createApp, h } from 'vue';
|
|
2
|
-
|
|
3
|
-
let rootComponent;
|
|
4
|
-
function setRootComponent(inComponent) {
|
|
5
|
-
rootComponent = inComponent;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const app = createApp({
|
|
9
|
-
data() {
|
|
10
|
-
return {
|
|
11
|
-
store: {
|
|
12
|
-
session: null,
|
|
13
|
-
globalError: window.gErr || null,
|
|
14
|
-
rootInjections: []
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
render() {
|
|
20
|
-
return h(rootComponent);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export { setRootComponent };
|
|
25
|
-
export default app;
|
package/src/components/alert.vue
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Modal class="vf-alert" :class="classes">
|
|
3
|
-
<template v-if="!this.isBare" v-slot:header>
|
|
4
|
-
<h1>{{ title }}</h1>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<div v-if="isHtml" v-html="message" class="user-message"></div>
|
|
8
|
-
<div v-else v-user-text="message"></div>
|
|
9
|
-
|
|
10
|
-
<template v-if="!this.isBare" v-slot:footer>
|
|
11
|
-
<template v-if="shouldConfirm">
|
|
12
|
-
<button class="primary" @click="ok" v-autofocus>Confirm</button>
|
|
13
|
-
<button class="default" @click="$dismiss()">Cancel</button>
|
|
14
|
-
</template>
|
|
15
|
-
<button v-else class="default" @click="ok" v-autofocus>OK</button>
|
|
16
|
-
</template>
|
|
17
|
-
</Modal>
|
|
18
|
-
</template>
|
|
19
|
-
|
|
20
|
-
<script>
|
|
21
|
-
import app from '../app';
|
|
22
|
-
import Modal from './modal.vue';
|
|
23
|
-
|
|
24
|
-
const classDef = {
|
|
25
|
-
components: {
|
|
26
|
-
Modal
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
data() {
|
|
30
|
-
return {
|
|
31
|
-
isBare: false,
|
|
32
|
-
isHtml: false,
|
|
33
|
-
classes: [],
|
|
34
|
-
title: null,
|
|
35
|
-
message: null,
|
|
36
|
-
shouldConfirm: false
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
created() {
|
|
41
|
-
if (typeof this.message == 'object') {
|
|
42
|
-
if (this.message.html) {
|
|
43
|
-
this.isHtml = true;
|
|
44
|
-
this.message = this.message.html;
|
|
45
|
-
} else if (this.message instanceof Error) {
|
|
46
|
-
let err = this.message;
|
|
47
|
-
err.handle();
|
|
48
|
-
|
|
49
|
-
this.message = err.userMessage;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
methods: {
|
|
55
|
-
ok() {
|
|
56
|
-
this.$dismiss(true);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export default classDef;
|
|
62
|
-
|
|
63
|
-
async function launchModal(context, classDef, ...args) {
|
|
64
|
-
classDef = { ...classDef, __modalId: Math.random().toString(36).substring(2, 10) };
|
|
65
|
-
return await context.$modal.apply(context, [classDef, ...args]);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
app.config.globalProperties.$alert = async function (title, message) {
|
|
69
|
-
return await launchModal(this, classDef, { title, message });
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
app.config.globalProperties.$confirm = async function (title, message, options) {
|
|
73
|
-
options = options || {};
|
|
74
|
-
const result = await launchModal(this, classDef, { title, message, shouldConfirm: true, ...options });
|
|
75
|
-
return !!result;
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
app.config.globalProperties.$confirmDestroy = function (title, message, options) {
|
|
79
|
-
options = options || {};
|
|
80
|
-
options.classes = options.classes || [];
|
|
81
|
-
options.classes.push('destructive');
|
|
82
|
-
return this.$confirm(title, message, options);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
app.config.globalProperties.$wait = function (title, message) {
|
|
86
|
-
if (title && !message) {
|
|
87
|
-
message = title;
|
|
88
|
-
title = undefined;
|
|
89
|
-
} else if (!title && !message) {
|
|
90
|
-
message = 'Please wait...';
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
let resolved = null;
|
|
94
|
-
let promise = new Promise((resolve, reject) => {
|
|
95
|
-
launchModal(this, classDef, { title, message, isBare: true, classes: ['wait'] }, resolve);
|
|
96
|
-
}).then(inResolved => (resolved = inResolved));
|
|
97
|
-
|
|
98
|
-
this.$endWait = async () => {
|
|
99
|
-
delete this.$endWait;
|
|
100
|
-
if (resolved) await resolved.$dismiss();
|
|
101
|
-
else await promise.then(() => resolved.$dismiss());
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
return this.$endWait;
|
|
105
|
-
};
|
|
106
|
-
</script>
|
|
107
|
-
|
|
108
|
-
<style lang="scss">
|
|
109
|
-
.vf-modal-wrap.vf-alert {
|
|
110
|
-
.vf-modal {
|
|
111
|
-
max-width: 800px;
|
|
112
|
-
|
|
113
|
-
> .vf-modal-content {
|
|
114
|
-
padding: 12px;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
&.wait {
|
|
119
|
-
.vf-modal-content {
|
|
120
|
-
text-align: center;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
&.destructive {
|
|
125
|
-
button.primary {
|
|
126
|
-
color: red;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
</style>
|
package/src/components/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import app from '../app';
|
|
2
|
-
import AjaxSelect from './ajax-select.vue';
|
|
3
|
-
app.component('AjaxSelect', AjaxSelect);
|
|
4
|
-
|
|
5
|
-
import Alert from './alert.vue';
|
|
6
|
-
app.component('Alert', Alert);
|
|
7
|
-
|
|
8
|
-
import Modal from './modal.vue';
|
|
9
|
-
app.component('Modal', Modal);
|
|
10
|
-
|
|
11
|
-
import SmartSelect from './smart-select.vue';
|
|
12
|
-
app.component('SmartSelect', SmartSelect);
|
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
|
-
}
|