@bagelink/vue 0.0.236-beta.0 → 0.0.239
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/Btn.vue.d.ts +6 -1
- package/dist/components/Btn.vue.d.ts.map +1 -1
- package/dist/components/DataPreview.vue.d.ts.map +1 -1
- package/dist/components/ListItem.vue.d.ts +4 -0
- package/dist/components/ListItem.vue.d.ts.map +1 -1
- package/dist/components/Modal.vue.d.ts +3 -1
- package/dist/components/Modal.vue.d.ts.map +1 -1
- package/dist/components/ModalForm.vue.d.ts +48 -41
- package/dist/components/ModalForm.vue.d.ts.map +1 -1
- package/dist/components/TableSchema.vue.d.ts +2 -0
- package/dist/components/TableSchema.vue.d.ts.map +1 -1
- package/dist/components/Title.vue.d.ts +9 -0
- package/dist/components/Title.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 +2 -2
- package/dist/components/form/inputs/SelectInput.vue.d.ts +4 -4
- package/dist/components/form/inputs/SelectInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/TextInput.vue.d.ts +1 -1
- package/dist/components/form/inputs/TextInput.vue.d.ts.map +1 -1
- package/dist/components/form/inputs/ToggleInput.vue.d.ts +6 -6
- package/dist/components/index.d.ts +1 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/whatsapp/form/MsgTemplate.vue.d.ts +4 -3
- package/dist/components/whatsapp/form/MsgTemplate.vue.d.ts.map +1 -1
- package/dist/index.cjs +1931 -2000
- package/dist/index.mjs +1932 -2001
- package/dist/plugins/bagel.d.ts +1 -1
- package/dist/plugins/modal.d.ts.map +1 -1
- package/dist/style.css +90 -84
- package/dist/types/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/components/Btn.vue +12 -25
- package/src/components/DataPreview.vue +4 -15
- package/src/components/ListItem.vue +5 -5
- package/src/components/Modal.vue +16 -24
- package/src/components/ModalForm.vue +25 -55
- package/src/components/TableSchema.vue +11 -54
- package/src/components/Title.vue +5 -1
- package/src/components/form/BglField.vue +6 -12
- package/src/components/form/BglForm.vue +1 -1
- package/src/components/form/inputs/DateInput.vue +6 -2
- package/src/components/form/inputs/SelectInput.vue +2 -2
- package/src/components/index.ts +1 -2
- package/src/components/whatsapp/form/MsgTemplate.vue +6 -12
- package/src/plugins/modal.ts +3 -6
- package/src/styles/theme.css +11 -3
- package/src/utils/index.ts +6 -5
- package/tsconfig.json +7 -3
- package/src/components/FormKitTable.vue +0 -280
- package/src/components/FormSchema.vue +0 -76
- package/src/components/ModalBglForm.vue +0 -106
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="table-list-wrap h-100">
|
|
3
|
-
<!-- <Transition name="fade"> -->
|
|
4
|
-
<div class="table-list">
|
|
5
|
-
<table class="infinite-wrapper">
|
|
6
|
-
<thead class="row first-row">
|
|
7
|
-
<th
|
|
8
|
-
class="col"
|
|
9
|
-
v-for="field in columns"
|
|
10
|
-
:key="field.id"
|
|
11
|
-
@click="sort(field.id)"
|
|
12
|
-
>
|
|
13
|
-
<div class="flex">
|
|
14
|
-
{{ field?.label || field.id }}
|
|
15
|
-
<div
|
|
16
|
-
class="list-arrows"
|
|
17
|
-
:class="{ sorted: sortField === field.id }"
|
|
18
|
-
>
|
|
19
|
-
<MaterialIcon
|
|
20
|
-
:class="{ desc: sortDirection === 'DESC' }"
|
|
21
|
-
icon="keyboard_arrow_up"
|
|
22
|
-
/>
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
</th>
|
|
26
|
-
</thead>
|
|
27
|
-
<tbody ref="infinite" class="rows infinite" :class="{ loading }">
|
|
28
|
-
<tr
|
|
29
|
-
@click="selectElement(row)"
|
|
30
|
-
class="row row-item position-relative"
|
|
31
|
-
v-for="row in data"
|
|
32
|
-
:key="row.id"
|
|
33
|
-
>
|
|
34
|
-
<td
|
|
35
|
-
class="col"
|
|
36
|
-
v-for="field in columns"
|
|
37
|
-
:key="`${field.id}-${row.id}`"
|
|
38
|
-
>
|
|
39
|
-
<slot
|
|
40
|
-
v-if="slots[field.id]"
|
|
41
|
-
:name="field.id"
|
|
42
|
-
:row="row"
|
|
43
|
-
:field="field"
|
|
44
|
-
/>
|
|
45
|
-
<div v-else>
|
|
46
|
-
<div v-if="field.inputType === 'DateInput'">
|
|
47
|
-
{{ new Date(row[field.id]).toLocaleDateString() }}
|
|
48
|
-
</div>
|
|
49
|
-
<div v-else-if="field.inputType === 'CheckInput'">
|
|
50
|
-
<MaterialIcon
|
|
51
|
-
icon="check"
|
|
52
|
-
class="pill green"
|
|
53
|
-
v-if="row[field.id]"
|
|
54
|
-
/>
|
|
55
|
-
<MaterialIcon icon="close" class="pill" v-else />
|
|
56
|
-
</div>
|
|
57
|
-
<div v-else-if="field.inputType === 'ItemRef' && row[field.id]">
|
|
58
|
-
<Btn
|
|
59
|
-
v-if="field.refCollection"
|
|
60
|
-
color="gray"
|
|
61
|
-
class="thin"
|
|
62
|
-
@click="
|
|
63
|
-
$router.push(
|
|
64
|
-
`/${field.refCollection}/${row[field.id].id}`
|
|
65
|
-
)
|
|
66
|
-
"
|
|
67
|
-
>
|
|
68
|
-
{{
|
|
69
|
-
field.refFields?.map((k) => row[field.id][k]).join(" ") ||
|
|
70
|
-
row[field.id].id
|
|
71
|
-
}}
|
|
72
|
-
<MaterialIcon icon="arrow_forward" />
|
|
73
|
-
</Btn>
|
|
74
|
-
<Btn
|
|
75
|
-
icon="receipt"
|
|
76
|
-
is="a"
|
|
77
|
-
thin
|
|
78
|
-
v-else-if="field.link"
|
|
79
|
-
:href="row[field.id][field.link]"
|
|
80
|
-
target="_blank"
|
|
81
|
-
>
|
|
82
|
-
{{
|
|
83
|
-
field.refFields?.map((k) => row[field.id][k]).join(" ") ||
|
|
84
|
-
row[field.id].id
|
|
85
|
-
}}
|
|
86
|
-
</Btn>
|
|
87
|
-
<div class="pill" v-else :class="getPillClass(row, field)">
|
|
88
|
-
{{
|
|
89
|
-
field.refFields?.map((k) => row[field.id][k]).join(" ") ||
|
|
90
|
-
row[field.id].id
|
|
91
|
-
}}
|
|
92
|
-
</div>
|
|
93
|
-
</div>
|
|
94
|
-
<div class="max-col-width" v-else>
|
|
95
|
-
{{ row[field.id] }}
|
|
96
|
-
</div>
|
|
97
|
-
</div>
|
|
98
|
-
</td>
|
|
99
|
-
</tr>
|
|
100
|
-
</tbody>
|
|
101
|
-
</table>
|
|
102
|
-
</div>
|
|
103
|
-
<!-- </Transition> -->
|
|
104
|
-
</div>
|
|
105
|
-
</template>
|
|
106
|
-
|
|
107
|
-
<script setup lang="ts">
|
|
108
|
-
import { computed, ref, useSlots } from 'vue';
|
|
109
|
-
import { BagelField, Btn, MaterialIcon } from '@bagelink/vue';
|
|
110
|
-
|
|
111
|
-
const slots = useSlots();
|
|
112
|
-
const loading = ref(true);
|
|
113
|
-
|
|
114
|
-
const props = defineProps<{
|
|
115
|
-
data: any[];
|
|
116
|
-
schema?: BagelField[];
|
|
117
|
-
}>();
|
|
118
|
-
|
|
119
|
-
const emit = defineEmits(['selectElement']);
|
|
120
|
-
|
|
121
|
-
const selectElement = (data: Record<string, any>) => {
|
|
122
|
-
emit('selectElement', data);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// const sortList = () => {};
|
|
126
|
-
const sortDirection = ref('');
|
|
127
|
-
const sortField = ref('');
|
|
128
|
-
|
|
129
|
-
const sort = (fieldname: string) => {
|
|
130
|
-
if (sortField.value === fieldname) {
|
|
131
|
-
if (sortDirection.value === 'ASC') sortDirection.value = 'DESC';
|
|
132
|
-
else sortField.value = '';
|
|
133
|
-
} else {
|
|
134
|
-
sortField.value = fieldname;
|
|
135
|
-
sortDirection.value = 'ASC';
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const columns = computed<BagelField[]>(
|
|
140
|
-
(): BagelField[] => props.schema ||
|
|
141
|
-
Object.keys(props.data[0]).map((k: string) => ({ id: k, inputType: 'PlainText' })),
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
function getPillClass(row: Record<string, any>, field: BagelField) {
|
|
145
|
-
return (
|
|
146
|
-
field.refFields?.map((k) => row[field.id][k]).join(' ') || row[field.id].id
|
|
147
|
-
);
|
|
148
|
-
}
|
|
149
|
-
</script>
|
|
150
|
-
|
|
151
|
-
<style scoped>
|
|
152
|
-
.Paid {
|
|
153
|
-
background-color: var(--bgl-green);
|
|
154
|
-
color: white;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.Error {
|
|
158
|
-
background-color: var(--bgl-red-tint);
|
|
159
|
-
color: var(--bgl-red);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
.list-arrows {
|
|
163
|
-
opacity: 0;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.list-arrows .icon-font {
|
|
167
|
-
transition: all ease-in-out 0.2s;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
.list-arrows.sorted {
|
|
171
|
-
opacity: 1;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
.list-arrows.sorted .desc {
|
|
175
|
-
transform: rotate(180deg);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
table {
|
|
179
|
-
border-collapse: separate;
|
|
180
|
-
border-spacing: 0 15px;
|
|
181
|
-
border-collapse: collapse;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
th {
|
|
185
|
-
font-weight: 400;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.row {
|
|
189
|
-
border-bottom: 1px solid var(--border-color);
|
|
190
|
-
cursor: pointer;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
.row.first-row {
|
|
194
|
-
font-size: 0.8rem;
|
|
195
|
-
color: var(--bgl-black-tint);
|
|
196
|
-
position: sticky;
|
|
197
|
-
top: 0;
|
|
198
|
-
z-index: 2;
|
|
199
|
-
background: var(--bgl-white);
|
|
200
|
-
height: 50px;
|
|
201
|
-
vertical-align: bottom;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
.row.first-row::after {
|
|
205
|
-
content: "";
|
|
206
|
-
border-bottom: 1px solid var(--border-color);
|
|
207
|
-
position: absolute;
|
|
208
|
-
left: 0;
|
|
209
|
-
right: 0;
|
|
210
|
-
bottom: -1px;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
.first-row .col {
|
|
214
|
-
cursor: pointer;
|
|
215
|
-
background: var(--bgl-white);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
.col {
|
|
219
|
-
white-space: nowrap;
|
|
220
|
-
padding: 14px;
|
|
221
|
-
transition: var(--bgl-transition);
|
|
222
|
-
line-height: 1;
|
|
223
|
-
padding-left: 1rem;
|
|
224
|
-
padding-right: 1rem;
|
|
225
|
-
align-items: center;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
.col > div {
|
|
229
|
-
display: flex;
|
|
230
|
-
gap: 0.5rem;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
.max-col-width {
|
|
234
|
-
max-width: 30vw;
|
|
235
|
-
overflow: hidden;
|
|
236
|
-
text-overflow: ellipsis;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
.col.check .icon-font {
|
|
240
|
-
border-radius: 100%;
|
|
241
|
-
background: var(--bgl-blue-20);
|
|
242
|
-
color: var(--bgl-primary);
|
|
243
|
-
width: 20px;
|
|
244
|
-
height: 20px;
|
|
245
|
-
display: flex;
|
|
246
|
-
align-items: center;
|
|
247
|
-
justify-content: center;
|
|
248
|
-
margin-top: -2px;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
.rows {
|
|
252
|
-
font-size: 0.8125em;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
.table-list {
|
|
256
|
-
height: 100%;
|
|
257
|
-
position: relative;
|
|
258
|
-
padding-left: 0 !important;
|
|
259
|
-
padding-right: 0 !important;
|
|
260
|
-
overflow: auto;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
.BagelTable .table-list {
|
|
264
|
-
overflow: unset;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
.row-item {
|
|
268
|
-
height: 50px;
|
|
269
|
-
transition: all 200ms ease;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
.row-item:hover {
|
|
273
|
-
background: var(--bgl-gray-light);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
.infinite-wrapper {
|
|
277
|
-
overflow-y: auto;
|
|
278
|
-
width: 100%;
|
|
279
|
-
}
|
|
280
|
-
</style>
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div>
|
|
3
|
-
<FormKit
|
|
4
|
-
type="form"
|
|
5
|
-
:modelValue="modelValue"
|
|
6
|
-
@update:modelValue="handleEmit"
|
|
7
|
-
@submit="runSubmit"
|
|
8
|
-
:submitLabel="i18nT('save')"
|
|
9
|
-
>
|
|
10
|
-
<FormKitSchema
|
|
11
|
-
:schema="schema"
|
|
12
|
-
:data="data"
|
|
13
|
-
/>
|
|
14
|
-
</FormKit>
|
|
15
|
-
<Btn
|
|
16
|
-
class="del-top"
|
|
17
|
-
v-if="modelValue?.id && onDelete"
|
|
18
|
-
@click="runDelete"
|
|
19
|
-
value="Delete"
|
|
20
|
-
flat
|
|
21
|
-
icon="delete"
|
|
22
|
-
color="red"
|
|
23
|
-
thin
|
|
24
|
-
/>
|
|
25
|
-
</div>
|
|
26
|
-
</template>
|
|
27
|
-
|
|
28
|
-
<script lang="ts" setup>
|
|
29
|
-
import { reactive } from 'vue';
|
|
30
|
-
import { type FormKitSchemaDefinition } from '@formkit/core';
|
|
31
|
-
|
|
32
|
-
import { Btn } from '@bagelink/vue';
|
|
33
|
-
import { useModal, useI18nT } from '..';
|
|
34
|
-
|
|
35
|
-
const { showModal } = useModal();
|
|
36
|
-
const i18nT = useI18nT();
|
|
37
|
-
const emits = defineEmits(['update:modelValue', 'submit']);
|
|
38
|
-
const handleEmit = (val: any) => emits('update:modelValue', val);
|
|
39
|
-
const runSubmit = (val: any) => emits('submit', val);
|
|
40
|
-
|
|
41
|
-
const props = defineProps<{
|
|
42
|
-
modelValue?: any;
|
|
43
|
-
schema: FormKitSchemaDefinition;
|
|
44
|
-
// eslint-disable-next-line no-unused-vars
|
|
45
|
-
onDelete?: ((id: string) => void);
|
|
46
|
-
}>();
|
|
47
|
-
|
|
48
|
-
const data = reactive({
|
|
49
|
-
...props.modelValue,
|
|
50
|
-
t: (val: string) => i18nT?.(val) || val,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const runDelete = () => {
|
|
54
|
-
showModal(
|
|
55
|
-
{
|
|
56
|
-
class: 'small-modal',
|
|
57
|
-
title: i18nT('Are you sure?'),
|
|
58
|
-
actions: [
|
|
59
|
-
{
|
|
60
|
-
value: 'Confirm',
|
|
61
|
-
color: 'red',
|
|
62
|
-
onClick: () => props.onDelete?.(data.id),
|
|
63
|
-
},
|
|
64
|
-
{ value: 'Cancel', color: 'gray' },
|
|
65
|
-
],
|
|
66
|
-
},
|
|
67
|
-
{ default: i18nT('form.deleteMessage') },
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
</script>
|
|
71
|
-
|
|
72
|
-
<style>
|
|
73
|
-
.del-top {
|
|
74
|
-
transform: translateY(-2.6rem);
|
|
75
|
-
}
|
|
76
|
-
</style>
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="bg-dark"
|
|
4
|
-
:class="{ 'is-side': side, 'is-active': isActive }"
|
|
5
|
-
@click="() => (dismissable ? closeModal() : '')"
|
|
6
|
-
@keydown.esc="closeModal"
|
|
7
|
-
>
|
|
8
|
-
<div
|
|
9
|
-
class="card modal"
|
|
10
|
-
@click.stop
|
|
11
|
-
>
|
|
12
|
-
<header class="tool-bar">
|
|
13
|
-
<slot name="toolbar" />
|
|
14
|
-
<Btn
|
|
15
|
-
:style="{ float: side ? 'left' : 'right' }"
|
|
16
|
-
flat
|
|
17
|
-
icon="close"
|
|
18
|
-
@click="closeModal"
|
|
19
|
-
/>
|
|
20
|
-
<h3 class="modal-title">
|
|
21
|
-
{{ title }}
|
|
22
|
-
</h3>
|
|
23
|
-
</header>
|
|
24
|
-
<BagelForm
|
|
25
|
-
:onDelete="onDelete ? runDelete : undefined"
|
|
26
|
-
v-model="formData"
|
|
27
|
-
@submit="runSubmit"
|
|
28
|
-
:schema="computedFormSchema"
|
|
29
|
-
/>
|
|
30
|
-
</div>
|
|
31
|
-
</div>
|
|
32
|
-
</template>
|
|
33
|
-
|
|
34
|
-
<script lang="ts" setup>
|
|
35
|
-
import { onMounted, onUnmounted } from 'vue';
|
|
36
|
-
import {
|
|
37
|
-
Btn, BtnOptions, useEscape, BagelForm, type BglFormSchemaT,
|
|
38
|
-
} from '@bagelink/vue';
|
|
39
|
-
import '../styles/modal.css';
|
|
40
|
-
|
|
41
|
-
const props = defineProps<{
|
|
42
|
-
side?: boolean;
|
|
43
|
-
title?: string;
|
|
44
|
-
dismissable?: boolean;
|
|
45
|
-
actions?: BtnOptions[];
|
|
46
|
-
schema: BglFormSchemaT | (() => BglFormSchemaT);
|
|
47
|
-
// eslint-disable-next-line no-unused-vars
|
|
48
|
-
onSubmit?: ((formData: any) => Promise<void>);
|
|
49
|
-
// eslint-disable-next-line no-unused-vars
|
|
50
|
-
onDelete?: ((id: string) => void);
|
|
51
|
-
}>();
|
|
52
|
-
|
|
53
|
-
const computedFormSchema = $computed(() => {
|
|
54
|
-
if (typeof props.schema === 'function') {
|
|
55
|
-
return props.schema();
|
|
56
|
-
}
|
|
57
|
-
return props.schema;
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
let isActive = $ref<boolean>(false);
|
|
61
|
-
|
|
62
|
-
const formData = defineModel<Record<string, any>>('modelValue', { default: {} });
|
|
63
|
-
|
|
64
|
-
const emit = defineEmits(['update:isModalVisible']);
|
|
65
|
-
|
|
66
|
-
const closeModal = () => {
|
|
67
|
-
isActive = false;
|
|
68
|
-
setTimeout(() => {
|
|
69
|
-
emit('update:isModalVisible', false);
|
|
70
|
-
}, 200);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const runSubmit = async () => {
|
|
74
|
-
try {
|
|
75
|
-
await props.onSubmit?.(formData.value);
|
|
76
|
-
closeModal();
|
|
77
|
-
} catch (err) {
|
|
78
|
-
console.error(err);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const runDelete = () => {
|
|
83
|
-
props.onDelete?.(formData.value?.id);
|
|
84
|
-
closeModal();
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const escapeKeyClose = (e: KeyboardEvent) => props?.dismissable && useEscape(e, () => closeModal());
|
|
88
|
-
|
|
89
|
-
onMounted(() => {
|
|
90
|
-
setTimeout(() => isActive = true, 1);
|
|
91
|
-
document.addEventListener('keydown', escapeKeyClose);
|
|
92
|
-
});
|
|
93
|
-
onUnmounted(() => document.removeEventListener('keydown', escapeKeyClose));
|
|
94
|
-
</script>
|
|
95
|
-
|
|
96
|
-
<style scoped>
|
|
97
|
-
.modal-title {
|
|
98
|
-
margin-top: 0.5rem;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
@media screen and (max-width: 910px) {
|
|
102
|
-
.modal-title {
|
|
103
|
-
margin-top: 1rem;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
</style>
|