@bagelink/vue 0.0.287 → 0.0.296
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/dist/components/Alert.vue.d.ts +30 -0
- package/dist/components/Alert.vue.d.ts.map +1 -0
- package/dist/components/Badge.vue.d.ts +20 -0
- package/dist/components/Badge.vue.d.ts.map +1 -0
- package/dist/components/Card.vue.d.ts +2 -2
- package/dist/components/MaterialIcon.vue.d.ts +2 -0
- package/dist/components/MaterialIcon.vue.d.ts.map +1 -1
- package/dist/components/Modal.vue.d.ts +4 -2
- package/dist/components/Modal.vue.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.cjs +157 -86
- package/dist/index.mjs +157 -86
- package/dist/plugins/modal.d.ts +2 -0
- package/dist/plugins/modal.d.ts.map +1 -1
- package/dist/style.css +16 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/materialIcon.d.ts +2 -0
- package/dist/types/materialIcon.d.ts.map +1 -0
- package/dist/types/materialIcons.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Alert.vue +44 -0
- package/src/components/Badge.vue +28 -0
- package/src/components/MaterialIcon.vue +6 -8
- package/src/components/Modal.vue +38 -53
- package/src/components/index.ts +2 -0
- package/src/plugins/modal.ts +3 -1
- package/src/types/index.ts +8 -8
- package/src/types/materialIcons.ts +3006 -3006
package/src/components/Modal.vue
CHANGED
|
@@ -1,76 +1,61 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
icon="close"
|
|
18
|
-
@click="closeModal"
|
|
19
|
-
/>
|
|
20
|
-
<Title
|
|
21
|
-
class="modal-title"
|
|
22
|
-
tag="h3"
|
|
23
|
-
v-if="title"
|
|
24
|
-
:label="title"
|
|
25
|
-
/>
|
|
26
|
-
</header>
|
|
27
|
-
<slot />
|
|
28
|
-
<footer class="modal-footer mt-3">
|
|
29
|
-
<Btn
|
|
30
|
-
v-for="(action, i) in actions"
|
|
31
|
-
:key="i"
|
|
32
|
-
@click="closeModal"
|
|
33
|
-
color="gray"
|
|
34
|
-
v-bind="action"
|
|
35
|
-
/>
|
|
36
|
-
<slot name="footer" />
|
|
37
|
-
</footer>
|
|
38
|
-
</Card>
|
|
39
|
-
</div>
|
|
2
|
+
<div class="bg-dark" :class="{ 'is-side': side, 'is-active': isVisible, 'bg-lignt': false }"
|
|
3
|
+
@click="() => (dismissable ? closeModal() : '')" @keydown.esc="closeModal">
|
|
4
|
+
<Card class="modal" @click.stop>
|
|
5
|
+
<header class="tool-bar">
|
|
6
|
+
<slot name="toolbar" />
|
|
7
|
+
<Btn :style="{ float: side ? 'left' : 'right' }" flat icon="close" @click="closeModal" />
|
|
8
|
+
<Title class="modal-title" tag="h3" v-if="title" :label="title" />
|
|
9
|
+
</header>
|
|
10
|
+
<slot />
|
|
11
|
+
<footer class="modal-footer mt-3">
|
|
12
|
+
<Btn v-for="(action, i) in actions" :key="i" @click="closeModal" color="gray" v-bind="action" />
|
|
13
|
+
<slot name="footer" />
|
|
14
|
+
</footer>
|
|
15
|
+
</Card>
|
|
16
|
+
</div>
|
|
40
17
|
</template>
|
|
41
18
|
|
|
42
19
|
<script lang="ts" setup>
|
|
43
|
-
import {
|
|
20
|
+
import { onUnmounted, watch } from 'vue';
|
|
44
21
|
import {
|
|
45
|
-
|
|
22
|
+
type BtnOptions, Btn, useEscape, Title, Card,
|
|
46
23
|
} from '@bagelink/vue';
|
|
47
24
|
import '../styles/modal.css';
|
|
48
25
|
|
|
49
26
|
const props = defineProps<{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
27
|
+
side?: boolean;
|
|
28
|
+
title?: string;
|
|
29
|
+
dismissable?: boolean;
|
|
30
|
+
actions?: BtnOptions[];
|
|
31
|
+
visible?: boolean;
|
|
54
32
|
}>();
|
|
55
33
|
|
|
56
|
-
let
|
|
34
|
+
let isVisible = $ref<boolean>(false);
|
|
57
35
|
|
|
58
|
-
|
|
36
|
+
watch(() => props.visible, (val) => {
|
|
37
|
+
if (val === isVisible || val === undefined) return;
|
|
38
|
+
if (val) openModal();
|
|
39
|
+
else closeModal();
|
|
40
|
+
}, { immediate: true });
|
|
41
|
+
|
|
42
|
+
const emit = defineEmits(['update:visible']);
|
|
59
43
|
|
|
60
44
|
const closeModal = () => {
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
isVisible = false;
|
|
46
|
+
setTimeout(() => emit('update:visible', false), 200);
|
|
63
47
|
};
|
|
64
48
|
|
|
65
49
|
defineExpose({ closeModal });
|
|
66
50
|
|
|
67
51
|
const escapeKeyClose = (e: KeyboardEvent) => props?.dismissable && useEscape(e, () => closeModal());
|
|
68
52
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
53
|
+
function openModal() {
|
|
54
|
+
setTimeout(() => isVisible = true, 1);
|
|
55
|
+
document.addEventListener('keydown', escapeKeyClose);
|
|
56
|
+
}
|
|
57
|
+
|
|
73
58
|
onUnmounted(() => {
|
|
74
|
-
|
|
59
|
+
document.removeEventListener('keydown', escapeKeyClose);
|
|
75
60
|
});
|
|
76
61
|
</script>
|
package/src/components/index.ts
CHANGED
|
@@ -21,6 +21,8 @@ export { default as Avatar } from './Avatar.vue';
|
|
|
21
21
|
export { default as Title } from './Title.vue';
|
|
22
22
|
export { default as Accordion } from './Accordion.vue';
|
|
23
23
|
export { default as ComboBox } from './ComboBox.vue';
|
|
24
|
+
export { default as Alert } from './Alert.vue';
|
|
25
|
+
export { default as Badge } from './Badge.vue';
|
|
24
26
|
|
|
25
27
|
export * from './form';
|
|
26
28
|
export * from './dashboard';
|
package/src/plugins/modal.ts
CHANGED
|
@@ -11,11 +11,13 @@ export interface ModalOptions {
|
|
|
11
11
|
side?: boolean;
|
|
12
12
|
actions?: BtnOptions[];
|
|
13
13
|
class?: string;
|
|
14
|
+
visible?: boolean;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export interface ModalFormOptions {
|
|
17
18
|
side?: boolean;
|
|
18
19
|
title?: string;
|
|
20
|
+
visible?: boolean;
|
|
19
21
|
dismissable?: boolean;
|
|
20
22
|
schema: BglFormSchemaT<any> | (() => BglFormSchemaT) | BglFormSchemaT
|
|
21
23
|
onSubmit?: (formData: any) => Promise<void>;
|
|
@@ -82,7 +84,7 @@ export const ModalPlugin: Plugin = {
|
|
|
82
84
|
data: () => ({ modalStack }),
|
|
83
85
|
render() {
|
|
84
86
|
return modalStack.map((modal, index) => {
|
|
85
|
-
const props = { ...modal.modalOptions, 'onUpdate:
|
|
87
|
+
const props = { ...modal.modalOptions, visible: true, 'onUpdate:visible': () => hideModal(index) };
|
|
86
88
|
if (modal.modalType === 'modalForm') return h(ModalForm, props as ModalFormOptions, modal.componentSlots);
|
|
87
89
|
return h(Modal, props, modal.componentSlots);
|
|
88
90
|
});
|
package/src/types/index.ts
CHANGED
|
@@ -11,11 +11,11 @@ export * from './BtnOptions';
|
|
|
11
11
|
export * from './BagelForm';
|
|
12
12
|
|
|
13
13
|
export type ThemeType = |
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
'light'
|
|
15
|
+
| 'red'
|
|
16
|
+
| 'gray'
|
|
17
|
+
| 'gray-light'
|
|
18
|
+
| 'black'
|
|
19
|
+
| 'green'
|
|
20
|
+
| 'primary'
|
|
21
|
+
| 'blue' // ! blue does nothing
|