@bagelink/vue 0.0.316 → 0.0.322
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/Badge.vue.d.ts +2 -2
- package/dist/components/Badge.vue.d.ts.map +1 -1
- package/dist/components/Card.vue.d.ts +2 -2
- package/dist/components/ComboBox.vue.d.ts +13 -2
- package/dist/components/ComboBox.vue.d.ts.map +1 -1
- package/dist/components/ListView.vue.d.ts.map +1 -1
- package/dist/components/Modal.vue.d.ts +1 -0
- package/dist/components/Modal.vue.d.ts.map +1 -1
- package/dist/components/NavBar.vue.d.ts.map +1 -1
- package/dist/components/form/BglField.vue.d.ts.map +1 -1
- package/dist/components/form/BglForm.vue.d.ts +50 -27
- package/dist/components/form/BglForm.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/DateInput.vue.d.ts +1 -0
- package/dist/components/form/inputs/TextInput.vue.d.ts +2 -0
- package/dist/components/form/inputs/TextInput.vue.d.ts.map +1 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/layout/Layout.vue.d.ts +3 -3
- package/dist/components/layout/Layout.vue.d.ts.map +1 -1
- package/dist/components/layout/SidebarMenu.vue.d.ts +1 -7
- package/dist/components/layout/SidebarMenu.vue.d.ts.map +1 -1
- package/dist/components/whatsapp/index.d.ts +0 -2
- package/dist/components/whatsapp/index.d.ts.map +1 -1
- package/dist/index.cjs +417 -568
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +417 -568
- package/dist/style.css +224 -258
- package/dist/types/BagelForm.d.ts +1 -1
- package/dist/types/BagelForm.d.ts.map +1 -1
- package/dist/types/NavLink.d.ts +2 -1
- package/dist/types/NavLink.d.ts.map +1 -1
- package/dist/types/materialIcons.d.ts +1 -1
- package/dist/types/materialIcons.d.ts.map +1 -1
- package/dist/utils/BagelFormUtils.d.ts +23 -0
- package/dist/utils/BagelFormUtils.d.ts.map +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/Badge.vue +2 -2
- package/src/components/Carousel.vue +137 -137
- package/src/components/ComboBox.vue +72 -49
- package/src/components/ListView.vue +28 -27
- package/src/components/Modal.vue +25 -23
- package/src/components/NavBar.vue +46 -40
- package/src/components/form/BglField.vue +33 -48
- package/src/components/form/BglForm.vue +34 -15
- package/src/components/form/inputs/TextInput.vue +121 -151
- package/src/components/index.ts +1 -1
- package/src/components/layout/Layout.vue +3 -2
- package/src/components/layout/SidebarMenu.vue +5 -12
- package/src/components/whatsapp/index.ts +2 -2
- package/src/styles/layout.css +24 -1
- package/src/styles/text.css +4 -0
- package/src/types/BagelForm.ts +7 -7
- package/src/types/NavLink.ts +2 -1
- package/src/types/materialIcons.ts +1183 -3006
- package/src/utils/BagelFormUtils.ts +58 -0
- package/src/utils/index.ts +3 -0
package/src/components/Modal.vue
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
<div
|
|
3
|
+
class="bg-dark" :class="{ 'is-side': side, 'is-active': isVisible, 'bg-lignt': false }"
|
|
4
|
+
@click="() => (dismissable ? closeModal() : '')" @keydown.esc="closeModal"
|
|
5
|
+
>
|
|
6
|
+
<Card class="modal" @click.stop>
|
|
7
|
+
<header class="tool-bar">
|
|
8
|
+
<slot name="toolbar" />
|
|
9
|
+
<Btn :style="{ float: side ? 'left' : 'right' }" flat icon="close" @click="closeModal" />
|
|
10
|
+
<Title class="modal-title" tag="h3" v-if="title" :label="title" />
|
|
11
|
+
</header>
|
|
12
|
+
<slot />
|
|
13
|
+
<footer class="modal-footer mt-3">
|
|
14
|
+
<Btn v-for="(action, i) in actions" :key="i" @click="closeModal" color="gray" v-bind="action" />
|
|
15
|
+
<slot name="footer" />
|
|
16
|
+
</footer>
|
|
17
|
+
</Card>
|
|
18
|
+
</div>
|
|
17
19
|
</template>
|
|
18
20
|
|
|
19
21
|
<script lang="ts" setup>
|
|
20
22
|
import { onMounted, onUnmounted, watch } from 'vue';
|
|
21
23
|
import {
|
|
22
|
-
|
|
24
|
+
type BtnOptions, Btn, useEscape, Title, Card,
|
|
23
25
|
} from '@bagelink/vue';
|
|
24
26
|
import '../styles/modal.css';
|
|
25
27
|
|
|
@@ -34,16 +36,16 @@ const props = defineProps<{
|
|
|
34
36
|
let isVisible = $ref<boolean>(false);
|
|
35
37
|
|
|
36
38
|
watch(() => props.visible, (val) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
if (val === isVisible || val === undefined) return;
|
|
40
|
+
if (val) openModal();
|
|
41
|
+
else closeModal();
|
|
40
42
|
}, { immediate: true });
|
|
41
43
|
|
|
42
44
|
const emit = defineEmits(['update:visible']);
|
|
43
45
|
|
|
44
46
|
const closeModal = () => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
isVisible = false;
|
|
48
|
+
setTimeout(() => emit('update:visible', false), 200);
|
|
47
49
|
};
|
|
48
50
|
|
|
49
51
|
defineExpose({ closeModal });
|
|
@@ -51,13 +53,13 @@ defineExpose({ closeModal });
|
|
|
51
53
|
const escapeKeyClose = (e: KeyboardEvent) => props?.dismissable && useEscape(e, () => closeModal());
|
|
52
54
|
|
|
53
55
|
function openModal() {
|
|
54
|
-
|
|
56
|
+
setTimeout(() => isVisible = true, 1);
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
onMounted(() => document.addEventListener('keydown', escapeKeyClose));
|
|
58
60
|
|
|
59
61
|
onUnmounted(() => {
|
|
60
|
-
|
|
62
|
+
document.removeEventListener('keydown', escapeKeyClose);
|
|
61
63
|
});
|
|
62
64
|
</script>
|
|
63
65
|
|
|
@@ -1,36 +1,42 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
<div :class="{ open: isOpen, closed: !isOpen }">
|
|
3
|
+
<slot name="top" />
|
|
4
|
+
<div
|
|
5
|
+
class="nav-expend" @click="isOpen = !isOpen" @keypress.enter="isOpen = !isOpen" role="button"
|
|
6
|
+
aria-label="Toggle Navigation" tabindex="0"
|
|
7
|
+
>
|
|
8
|
+
<MaterialIcon icon="chevron_right" class="top-arrow" />
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<div class="full-nav">
|
|
12
|
+
<div class="nav-scroll">
|
|
13
|
+
<div class="nav-links-wrapper">
|
|
14
|
+
<component
|
|
15
|
+
:is="link.to?'router-link':'div'" v-for="link in links" class="nav-button" :to="link.to"
|
|
16
|
+
:key="link.label" @click="link.onClick?.()"
|
|
17
|
+
>
|
|
18
|
+
<MaterialIcon :icon="link.icon" />
|
|
19
|
+
<div class="tooltip">
|
|
20
|
+
{{ link.label }}
|
|
21
|
+
</div>
|
|
22
|
+
</component>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<div class="bot-buttons-wrapper">
|
|
27
|
+
<component
|
|
28
|
+
:is="link.to?'router-link':'div'" v-for="link in footerLinks" class="nav-button" :to="link.to"
|
|
29
|
+
@click="link.onClick?.()" :key="link.label"
|
|
30
|
+
>
|
|
31
|
+
<MaterialIcon :icon="link.icon" />
|
|
32
|
+
<div class="tooltip">
|
|
33
|
+
{{ link.label }}
|
|
34
|
+
</div>
|
|
35
|
+
</component>
|
|
36
|
+
<slot name="floor" />
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
34
40
|
</template>
|
|
35
41
|
|
|
36
42
|
<script lang="ts" setup>
|
|
@@ -40,20 +46,20 @@ import { MaterialIcon } from '@bagelink/vue';
|
|
|
40
46
|
const isOpen = $ref(true);
|
|
41
47
|
|
|
42
48
|
withDefaults(
|
|
43
|
-
|
|
49
|
+
defineProps<{
|
|
44
50
|
footerLinks?: NavLink[];
|
|
45
51
|
links?: NavLink[];
|
|
46
52
|
homeIcon?: MaterialIcons;
|
|
47
53
|
homeLabel?: string;
|
|
48
54
|
homeTo?: string;
|
|
49
55
|
}>(),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
{
|
|
57
|
+
homeIcon: 'home',
|
|
58
|
+
homeLabel: 'Home',
|
|
59
|
+
homeTo: '/',
|
|
60
|
+
links: () => [],
|
|
61
|
+
footerLinks: () => [],
|
|
62
|
+
},
|
|
57
63
|
);
|
|
58
64
|
</script>
|
|
59
65
|
|
|
@@ -1,73 +1,58 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
:placeholder="field.placeholder || field.label"
|
|
11
|
-
v-model="fieldData"
|
|
12
|
-
:defaultValue="field.defaultValue"
|
|
13
|
-
:options="field.options"
|
|
14
|
-
:helptext="field.helptext"
|
|
15
|
-
@update:modelValue="($event: any) => field?.onUpdate?.($event, formData)"
|
|
16
|
-
>
|
|
17
|
-
{{ field.transform?.(fieldData, modelValue) || fieldData || '' }}
|
|
18
|
-
<BglField
|
|
19
|
-
v-model="formData"
|
|
20
|
-
v-for="(child, ii) in field.children"
|
|
21
|
-
:key="child.id || ii"
|
|
22
|
-
:field="child"
|
|
23
|
-
/>
|
|
24
|
-
</component>
|
|
2
|
+
<component :required="field.required" v-bind="bindAttrs(field?.attrs || {}, fieldData, modelValue)"
|
|
3
|
+
:class="classify(fieldData, modelValue, field.class, field.attrs?.class)" v-if="vIf" :is="is" :label="field.label"
|
|
4
|
+
:id="field.id" :placeholder="field.placeholder || field.label" v-model="fieldData"
|
|
5
|
+
:defaultValue="field.defaultValue" :options="bindAttrs({ options: field.options }, fieldData, modelValue).options"
|
|
6
|
+
:helptext="field.helptext" @update:modelValue="($event: any) => field?.onUpdate?.($event, formData)">
|
|
7
|
+
{{ field.transform?.(fieldData, modelValue) || fieldData || '' }}
|
|
8
|
+
<BglField v-model="formData" v-for="(child, ii) in field.children" :key="child.id || ii" :field="child" />
|
|
9
|
+
</component>
|
|
25
10
|
</template>
|
|
26
11
|
|
|
27
12
|
<script lang="ts" setup>
|
|
28
13
|
import {
|
|
29
|
-
|
|
14
|
+
type Field, bindAttrs, classify, ComboBox, TextInput, ToggleInput, CheckInput,
|
|
30
15
|
} from '@bagelink/vue';
|
|
31
16
|
|
|
32
17
|
const props = withDefaults(defineProps<{
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
field: Field
|
|
19
|
+
modelValue: Record<string, any>
|
|
35
20
|
}>(), {
|
|
36
|
-
|
|
21
|
+
modelValue: () => ({}),
|
|
37
22
|
});
|
|
38
23
|
|
|
39
24
|
const is = $computed(() => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
25
|
+
if (props.field.$el === 'text') return TextInput;
|
|
26
|
+
if (props.field.$el === 'select') return ComboBox;
|
|
27
|
+
if (props.field.$el === 'toggle') return ToggleInput;
|
|
28
|
+
if (props.field.$el === 'check') return CheckInput;
|
|
29
|
+
return props.field.$el || 'div';
|
|
45
30
|
});
|
|
46
31
|
|
|
47
32
|
const emit = defineEmits(['update:modelValue']);
|
|
48
33
|
|
|
49
34
|
const formData = $computed({
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
get: () => props.modelValue,
|
|
36
|
+
set: (val: any) => emit('update:modelValue', val),
|
|
52
37
|
});
|
|
53
38
|
|
|
54
39
|
const fieldData = $computed({
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
40
|
+
set: (val: any) => {
|
|
41
|
+
if (!props.field.id) return;
|
|
42
|
+
const data = { ...props.modelValue } || {};
|
|
43
|
+
data[props.field.id] = val;
|
|
44
|
+
emit('update:modelValue', data);
|
|
45
|
+
},
|
|
46
|
+
get: () => (props.field.id ? props.modelValue[props.field.id] : props.field.defaultValue || ''),
|
|
62
47
|
});
|
|
63
48
|
|
|
64
49
|
const vIf = $computed(() => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
50
|
+
if (props.field['v-if'] === undefined) return true;
|
|
51
|
+
if (typeof props.field['v-if'] === 'boolean') return props.field['v-if'];
|
|
52
|
+
if (typeof props.field['v-if'] === 'string') return true;
|
|
53
|
+
if (typeof props.field['v-if'] === 'function') {
|
|
54
|
+
return props.field['v-if']?.(fieldData, formData);
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
72
57
|
});
|
|
73
58
|
</script>
|
|
@@ -2,32 +2,39 @@
|
|
|
2
2
|
<template v-if="id">
|
|
3
3
|
<BglField v-for="(field, i) in schema" :key="field.id || `${i}p`" :field="field" v-model="data" />
|
|
4
4
|
</template>
|
|
5
|
-
<form v-else ref="form" @submit.prevent="runSubmit">
|
|
5
|
+
<form v-else-if="(!slots.success || formStatus !== 'success')" ref="form" @submit.prevent="runSubmit">
|
|
6
6
|
<Title tag="h4" :label="label" v-if="label" />
|
|
7
7
|
<BglField v-for="(field, i) in schema" :key="field.id || `${i}p`" :field="field" v-model="data" />
|
|
8
8
|
<slot name="submit" />
|
|
9
|
-
<
|
|
9
|
+
<button @click="runSubmit">
|
|
10
|
+
Click
|
|
11
|
+
</button>
|
|
10
12
|
</form>
|
|
13
|
+
<slot v-if="formStatus === 'success'" name="success" />
|
|
14
|
+
<slot v-if="formStatus === 'error'" name="error" :message="error" />
|
|
11
15
|
</template>
|
|
12
16
|
|
|
13
17
|
<script lang="ts" setup>
|
|
18
|
+
import { useSlots } from 'vue';
|
|
14
19
|
import {
|
|
15
20
|
useModal, BglField, Title,
|
|
16
21
|
} from '@bagelink/vue';
|
|
17
22
|
|
|
18
23
|
import { type BglFormSchemaT } from '@bagelink/vue';
|
|
19
24
|
|
|
25
|
+
const slots = useSlots();
|
|
26
|
+
|
|
20
27
|
const { showModal } = useModal();
|
|
21
28
|
|
|
22
29
|
const props = withDefaults(
|
|
23
30
|
defineProps<{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
label?: string;
|
|
32
|
+
id?: string;
|
|
33
|
+
schema: BglFormSchemaT<any>;
|
|
34
|
+
modelValue?: Record<string, any>;
|
|
35
|
+
onDelete?: ((id: string) => void);
|
|
36
|
+
onSubmit?: ((data: any) => void);
|
|
37
|
+
}>(),
|
|
31
38
|
{
|
|
32
39
|
modelValue: () => ({}),
|
|
33
40
|
},
|
|
@@ -35,7 +42,7 @@ const props = withDefaults(
|
|
|
35
42
|
|
|
36
43
|
const instAt = new Date();
|
|
37
44
|
const timeSinceInst = () => new Date().getTime() - instAt.getTime();
|
|
38
|
-
|
|
45
|
+
let formData = $ref(props.modelValue);
|
|
39
46
|
const emit = defineEmits(['update:modelValue', 'submit', 'dirty']);
|
|
40
47
|
let isDirty = $ref(false);
|
|
41
48
|
const data = $computed({
|
|
@@ -44,9 +51,10 @@ const data = $computed({
|
|
|
44
51
|
emit('dirty');
|
|
45
52
|
isDirty = true;
|
|
46
53
|
}
|
|
54
|
+
formData = val;
|
|
47
55
|
emit('update:modelValue', val);
|
|
48
56
|
},
|
|
49
|
-
get: () => props.modelValue ||
|
|
57
|
+
get: () => props.modelValue || formData,
|
|
50
58
|
});
|
|
51
59
|
const form = $ref<HTMLFormElement>();
|
|
52
60
|
|
|
@@ -54,10 +62,21 @@ const validateForm = () => form?.reportValidity?.();
|
|
|
54
62
|
|
|
55
63
|
const clearForm = () => Object.assign(data, {});
|
|
56
64
|
|
|
65
|
+
type FormStatus = 'idle' | 'loading' | 'success' | 'error' ;
|
|
66
|
+
|
|
67
|
+
let formStatus = $ref<FormStatus>('idle');
|
|
68
|
+
|
|
57
69
|
const runSubmit = () => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
console.log('runSubmit');
|
|
71
|
+
try {
|
|
72
|
+
validateForm();
|
|
73
|
+
props.onSubmit(data);
|
|
74
|
+
// emit('submit', data);
|
|
75
|
+
clearForm();
|
|
76
|
+
formStatus = 'success';
|
|
77
|
+
} catch (e) {
|
|
78
|
+
formStatus = 'error';
|
|
79
|
+
}
|
|
61
80
|
};
|
|
62
81
|
|
|
63
82
|
const i18nT = (val: string) => val;
|
|
@@ -85,6 +104,6 @@ defineExpose({ validateForm, deleteItem, isDirty });
|
|
|
85
104
|
|
|
86
105
|
<style>
|
|
87
106
|
.del-top {
|
|
88
|
-
|
|
107
|
+
transform: translateY(-2.6rem);
|
|
89
108
|
}
|
|
90
109
|
</style>
|