@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/src/components/modal.vue
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Teleport to="#vf-modal-target">
|
|
3
|
-
<div :id="id" class="vf-overlay vf-modal-wrap" :class="class">
|
|
4
|
-
<form
|
|
5
|
-
action="."
|
|
6
|
-
class="vf-modal"
|
|
7
|
-
:class="{ scrolls: $isPropTruthy(this.scrolls) }"
|
|
8
|
-
@submit.prevent="$emit('formSubmit')"
|
|
9
|
-
>
|
|
3
|
+
<div :id="id" class="vf-overlay vf-modal-wrap" :class="props.class" ref="overlay">
|
|
4
|
+
<form action="." class="vf-modal" :class="{ scrolls }" @submit.prevent="$emit('formSubmit')">
|
|
10
5
|
<div v-if="$slots.header" class="vf-modal-header">
|
|
11
6
|
<slot name="header" />
|
|
12
|
-
<i v-if="
|
|
7
|
+
<i v-if="props.closeX" class="close" @click="closeParent"></i>
|
|
13
8
|
</div>
|
|
14
9
|
<div class="vf-modal-content">
|
|
15
10
|
<slot />
|
|
@@ -22,137 +17,57 @@
|
|
|
22
17
|
</Teleport>
|
|
23
18
|
</template>
|
|
24
19
|
|
|
25
|
-
<script>
|
|
26
|
-
|
|
27
|
-
props: ['id', 'closeOnMaskClick', 'scrolls', 'closeX', 'class'],
|
|
28
|
-
emits: ['formSubmit'],
|
|
29
|
-
|
|
30
|
-
beforeCreate() {
|
|
31
|
-
const targetEl = document.getElementById('vf-modal-target') ?? document.createElement('div');
|
|
32
|
-
targetEl.id = 'vf-modal-target';
|
|
33
|
-
targetEl.removeAttribute('inert');
|
|
34
|
-
document.body.appendChild(targetEl);
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
mounted() {
|
|
38
|
-
window.addEventListener('keydown', this.handleEscapeKey);
|
|
39
|
-
document.body.classList.add('vf-modal-open');
|
|
40
|
-
|
|
41
|
-
if (this.$isPropTruthy(this.closeOnMaskClick)) {
|
|
42
|
-
this.$el.addEventListener('click', e => {
|
|
43
|
-
if (e.target == this.$el) this.$parent.$dismiss();
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
unmounted() {
|
|
49
|
-
window.removeEventListener('keydown', this.handleEscapeKey);
|
|
50
|
-
|
|
51
|
-
let areOtherModalsOpen = document.body.querySelectorAll('.vf-modal').length > 0;
|
|
52
|
-
areOtherModalsOpen || document.body.classList.remove('vf-modal-open');
|
|
53
|
-
},
|
|
54
|
-
|
|
55
|
-
methods: {
|
|
56
|
-
handleEscapeKey(e) {
|
|
57
|
-
if (e.key === 'Esc' || e.key === 'Escape') {
|
|
58
|
-
const modalWraps = document.querySelectorAll('.vf-modal-wrap');
|
|
59
|
-
if (modalWraps[modalWraps.length - 1] === this.$el) {
|
|
60
|
-
this.$parent.$dismiss();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
import app from '../app';
|
|
68
|
-
import { markRaw } from 'vue';
|
|
69
|
-
import cloneDeep from 'lodash/cloneDeep';
|
|
70
|
-
|
|
71
|
-
let modalConfigs = {};
|
|
72
|
-
|
|
73
|
-
function bootModal(modalId) {
|
|
74
|
-
const config = modalConfigs[modalId];
|
|
75
|
-
|
|
76
|
-
this.$modalOpener = config.opener;
|
|
77
|
-
this.$modalResult = undefined;
|
|
78
|
-
|
|
79
|
-
this.$options.storeParent = this.$modalOpener;
|
|
80
|
-
|
|
81
|
-
let originalDataFn = this.$options.data;
|
|
82
|
-
this.$options.data = function () {
|
|
83
|
-
const injectedData = config.injectedData || {};
|
|
84
|
-
const keepOriginalKeys = this.$options.keepOriginal || [];
|
|
85
|
-
let data = originalDataFn ? originalDataFn.apply(this) : {};
|
|
86
|
-
|
|
87
|
-
for (let key in injectedData) {
|
|
88
|
-
if (!keepOriginalKeys.includes(key)) {
|
|
89
|
-
if (
|
|
90
|
-
injectedData[key] !== null &&
|
|
91
|
-
typeof injectedData[key] == 'object' &&
|
|
92
|
-
injectedData[key].constructor === Object
|
|
93
|
-
) {
|
|
94
|
-
data[key] = cloneDeep(injectedData[key]);
|
|
95
|
-
} else {
|
|
96
|
-
data[key] = injectedData[key];
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
20
|
+
<script lang="ts" setup>
|
|
21
|
+
import { defineProps, getCurrentInstance, onBeforeUnmount, onMounted, ref } from 'vue';
|
|
100
22
|
|
|
101
|
-
|
|
102
|
-
};
|
|
23
|
+
import { removeModalInjectionByInternalInstance } from './modal-container';
|
|
103
24
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
25
|
+
const props = defineProps<{
|
|
26
|
+
id?: string;
|
|
27
|
+
closeOnMaskClick?: boolean;
|
|
28
|
+
scrolls?: boolean;
|
|
29
|
+
closeX?: boolean;
|
|
30
|
+
class?: string;
|
|
31
|
+
}>();
|
|
111
32
|
|
|
112
|
-
|
|
33
|
+
defineEmits(['formSubmit']);
|
|
113
34
|
|
|
114
|
-
|
|
115
|
-
|
|
35
|
+
const overlay = ref<HTMLElement>();
|
|
36
|
+
|
|
37
|
+
onMounted(() => {
|
|
38
|
+
window.addEventListener('keydown', handleEscapeKey);
|
|
39
|
+
document.body.classList.add('vf-modal-open');
|
|
40
|
+
|
|
41
|
+
if (props.closeOnMaskClick) {
|
|
42
|
+
overlay.value?.addEventListener('click', handleOverlayClick);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
116
45
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
});
|
|
122
|
-
}, 0);
|
|
123
|
-
});
|
|
124
|
-
};
|
|
46
|
+
onBeforeUnmount(() => {
|
|
47
|
+
let areOtherModalsOpen = document.body.querySelectorAll('.vf-modal').length > 0;
|
|
48
|
+
areOtherModalsOpen || document.body.classList.remove('vf-modal-open');
|
|
49
|
+
});
|
|
125
50
|
|
|
126
|
-
|
|
51
|
+
function handleOverlayClick(e: MouseEvent) {
|
|
52
|
+
if (e.target == overlay.value) {
|
|
53
|
+
closeParent();
|
|
54
|
+
}
|
|
127
55
|
}
|
|
128
56
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
57
|
+
function handleEscapeKey(e: KeyboardEvent) {
|
|
58
|
+
if (e.key === 'Esc' || e.key === 'Escape') {
|
|
59
|
+
const modalWraps = document.querySelectorAll('.vf-modal-wrap');
|
|
60
|
+
// make sure we're the topmost modal
|
|
61
|
+
if (modalWraps[modalWraps.length - 1] === overlay.value) {
|
|
62
|
+
closeParent();
|
|
63
|
+
}
|
|
133
64
|
}
|
|
134
|
-
}
|
|
65
|
+
}
|
|
135
66
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
modalConfigs[modalId] = {
|
|
142
|
-
opener: this,
|
|
143
|
-
injectedData,
|
|
144
|
-
instanceCreationCallback,
|
|
145
|
-
resolve
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
this.$nextTick(() => {
|
|
149
|
-
app.vm.store.rootInjections.push(markRaw(classDef));
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// TODO: see about a injecting a root modal container & HMR inside it
|
|
155
|
-
// modals, on render, can hot move themselves to body end
|
|
67
|
+
function closeParent() {
|
|
68
|
+
const instance = getCurrentInstance();
|
|
69
|
+
removeModalInjectionByInternalInstance(instance!);
|
|
70
|
+
}
|
|
156
71
|
</script>
|
|
157
72
|
|
|
158
73
|
<style lang="scss">
|