@bagelink/vue 0.0.168 → 0.0.170
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/DataPreview.vue.d.ts +3 -19
- package/dist/components/DataPreview.vue.d.ts.map +1 -1
- package/dist/components/FormSchema.vue.d.ts +3 -19
- package/dist/components/FormSchema.vue.d.ts.map +1 -1
- package/dist/components/PersonPreview.vue.d.ts +1 -1
- package/dist/components/PersonPreview.vue.d.ts.map +1 -1
- package/dist/components/formkit/FileUploader.vue.d.ts.map +1 -1
- package/dist/components/formkit/index.d.ts +10 -8
- package/dist/components/formkit/index.d.ts.map +1 -1
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.cjs +206 -351
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +206 -351
- package/dist/plugins/bagel.d.ts +3 -0
- package/dist/plugins/bagel.d.ts.map +1 -1
- package/dist/style.css +140 -273
- package/package.json +1 -1
- package/src/components/DataPreview.vue +5 -6
- package/src/components/FormSchema.vue +7 -10
- package/src/components/PersonPreview.vue +147 -123
- package/src/components/formkit/FileUploader.vue +264 -254
- package/src/components/formkit/index.ts +10 -10
- package/src/components/index.ts +0 -1
- package/src/index.ts +1 -1
- package/src/plugins/bagel.ts +17 -1
- package/src/components/FileUploader.vue +0 -353
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createInput } from '@formkit/vue';
|
|
2
|
+
import type { FormKitTypeDefinition } from '@formkit/core';
|
|
2
3
|
import ContactArrayFormKit from './ContactArrayFormKit.vue';
|
|
3
4
|
import AddressArray from './AddressArray.vue';
|
|
4
5
|
import BankDetailsArray from './BankDetailsArray.vue';
|
|
@@ -8,16 +9,14 @@ import FileUploader from './FileUploader.vue';
|
|
|
8
9
|
import PPV from '../PersonPreviewFormkit.vue';
|
|
9
10
|
import TextVariableExamples from '../whatsapp/form/TextVariableExamples.vue';
|
|
10
11
|
|
|
11
|
-
const ContactArrayInput = createInput(ContactArrayFormKit);
|
|
12
|
-
const AddressInput = createInput(AddressArray);
|
|
13
|
-
const BankDetailsInput = createInput(BankDetailsArray);
|
|
14
|
-
const MiscFieldsInput = createInput(MiscFieldsBtns);
|
|
15
|
-
const ToggleSwitchInput = createInput(Toggle);
|
|
16
|
-
const FileUploadInput = createInput(FileUploader
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const TextVariablesInput = createInput(TextVariableExamples);
|
|
20
|
-
const PersonPreviewInput = createInput(PPV);
|
|
12
|
+
const ContactArrayInput: FormKitTypeDefinition = createInput(ContactArrayFormKit);
|
|
13
|
+
const AddressInput: FormKitTypeDefinition = createInput(AddressArray);
|
|
14
|
+
const BankDetailsInput: FormKitTypeDefinition = createInput(BankDetailsArray);
|
|
15
|
+
const MiscFieldsInput: FormKitTypeDefinition = createInput(MiscFieldsBtns);
|
|
16
|
+
const ToggleSwitchInput: FormKitTypeDefinition = createInput(Toggle);
|
|
17
|
+
const FileUploadInput: FormKitTypeDefinition = createInput(FileUploader);
|
|
18
|
+
const TextVariablesInput: FormKitTypeDefinition = createInput(TextVariableExamples);
|
|
19
|
+
const PersonPreviewInput: FormKitTypeDefinition = createInput(PPV);
|
|
21
20
|
|
|
22
21
|
export {
|
|
23
22
|
TextVariablesInput,
|
|
@@ -30,6 +29,7 @@ export {
|
|
|
30
29
|
FileUploadInput,
|
|
31
30
|
};
|
|
32
31
|
|
|
32
|
+
export { default as FileUploader } from './FileUploader.vue';
|
|
33
33
|
export type { BankDetailsContext } from './BankDetailsArray.vue';
|
|
34
34
|
export type { AddressArrContext } from './AddressArray.vue';
|
|
35
35
|
export type { ContactArrContext } from './ContactArrayFormKit.vue';
|
package/src/components/index.ts
CHANGED
|
@@ -18,7 +18,6 @@ export { default as RouterWrapper } from './RouterWrapper.vue';
|
|
|
18
18
|
export { default as ContactSubmissions } from './ContactSubmissions.vue';
|
|
19
19
|
export { default as PersonPreview } from './PersonPreview.vue';
|
|
20
20
|
export { default as DataPreview } from './DataPreview.vue';
|
|
21
|
-
export { default as FileUploader } from './FileUploader.vue';
|
|
22
21
|
|
|
23
22
|
export * from './charts';
|
|
24
23
|
export * from './formkit';
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export {
|
|
2
|
-
BagelVue, type BagelOptions, bagelInjectionKey, useBagel,
|
|
2
|
+
BagelVue, type BagelOptions, bagelInjectionKey, useBagel, useI18nT, i18nTInjectionKey,
|
|
3
3
|
} from './plugins/bagel';
|
|
4
4
|
export { ModalPlugin, useModal } from './plugins/modal';
|
|
5
5
|
export * from './utils';
|
package/src/plugins/bagel.ts
CHANGED
|
@@ -3,6 +3,10 @@ import type { InjectionKey, Plugin } from 'vue';
|
|
|
3
3
|
import { Bagel } from '@bagelink/sdk';
|
|
4
4
|
|
|
5
5
|
export const bagelInjectionKey = Symbol('bagel') as InjectionKey<Bagel>;
|
|
6
|
+
export const i18nTInjectionKey = Symbol('bagel') as InjectionKey<
|
|
7
|
+
// eslint-disable-next-line no-unused-vars
|
|
8
|
+
(key: string) => string
|
|
9
|
+
>;
|
|
6
10
|
|
|
7
11
|
export function useBagel() {
|
|
8
12
|
const bagel = inject(bagelInjectionKey);
|
|
@@ -11,16 +15,28 @@ export function useBagel() {
|
|
|
11
15
|
return bagel;
|
|
12
16
|
}
|
|
13
17
|
|
|
18
|
+
export function useI18nT() {
|
|
19
|
+
const i18nT = inject(i18nTInjectionKey);
|
|
20
|
+
if (!i18nT) throw new Error('No i18nT provided');
|
|
21
|
+
|
|
22
|
+
return i18nT;
|
|
23
|
+
}
|
|
24
|
+
|
|
14
25
|
export interface BagelOptions {
|
|
15
26
|
host: string
|
|
16
27
|
// eslint-disable-next-line no-unused-vars
|
|
17
|
-
onError?: (err: Error) => void
|
|
28
|
+
onError?: (err: Error) => void,
|
|
29
|
+
// eslint-disable-next-line no-unused-vars
|
|
30
|
+
i18nT?: (key: string) => string
|
|
18
31
|
}
|
|
19
32
|
|
|
20
33
|
export const BagelVue: Plugin = {
|
|
21
34
|
install: (app, options: BagelOptions) => {
|
|
22
35
|
const bagel = new Bagel({ host: options.host, onError: options.onError });
|
|
36
|
+
|
|
23
37
|
app.config.globalProperties.$bagel = bagel;
|
|
24
38
|
app.provide(bagelInjectionKey, bagel);
|
|
39
|
+
app.config.globalProperties.$i18T = options?.i18nT || ((key: string) => key);
|
|
40
|
+
app.provide(i18nTInjectionKey, options?.i18nT || ((key: string) => key));
|
|
25
41
|
},
|
|
26
42
|
};
|
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="files-wrapper flex">
|
|
3
|
-
<div
|
|
4
|
-
ref="dropZoneEl"
|
|
5
|
-
class="drop-zone flex-grow"
|
|
6
|
-
@click="openFileDialog"
|
|
7
|
-
@dragenter="draggingOver = true"
|
|
8
|
-
@drop.prevent.stop="onDrop"
|
|
9
|
-
>
|
|
10
|
-
<Transition name="pop">
|
|
11
|
-
<div
|
|
12
|
-
ref="dropCircle"
|
|
13
|
-
v-if="draggingOver"
|
|
14
|
-
class="drop-circle"
|
|
15
|
-
/>
|
|
16
|
-
</Transition>
|
|
17
|
-
<div class="img-label">
|
|
18
|
-
<p>
|
|
19
|
-
{{ dragDropLabel }} <span>{{ browseLabel }}</span>
|
|
20
|
-
</p>
|
|
21
|
-
</div>
|
|
22
|
-
<div class="uploading-wrap">
|
|
23
|
-
<div
|
|
24
|
-
v-for="(item, index) in files"
|
|
25
|
-
:class="{ uploading: item.uploading }"
|
|
26
|
-
:key="index"
|
|
27
|
-
>
|
|
28
|
-
<div class="load-file-bar">
|
|
29
|
-
<p>{{ item.file.name }}</p>
|
|
30
|
-
<div
|
|
31
|
-
class="pie"
|
|
32
|
-
:style="`--p:${item.progress}`"
|
|
33
|
-
style="--b: 2px"
|
|
34
|
-
>
|
|
35
|
-
<span>{{ `${item.progress}` }}</span>
|
|
36
|
-
</div>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
<input
|
|
42
|
-
class="file-input"
|
|
43
|
-
type="file"
|
|
44
|
-
@change="handleFileInput"
|
|
45
|
-
ref="fileInputEl"
|
|
46
|
-
:multiple="!singleFile"
|
|
47
|
-
/>
|
|
48
|
-
</div>
|
|
49
|
-
</template>
|
|
50
|
-
|
|
51
|
-
<script setup lang="ts">
|
|
52
|
-
import { ref, onMounted, onUnmounted } from "vue";
|
|
53
|
-
import { useBagel } from "..";
|
|
54
|
-
|
|
55
|
-
const bagel = useBagel();
|
|
56
|
-
|
|
57
|
-
const draggingOver = ref(false);
|
|
58
|
-
const dropCircle = ref<HTMLElement>();
|
|
59
|
-
const dropZoneEl = ref<HTMLElement>();
|
|
60
|
-
const fileInputEl = ref<HTMLInputElement>();
|
|
61
|
-
const circleTop = ref("0");
|
|
62
|
-
const circleLeft = ref("0");
|
|
63
|
-
const files = ref<
|
|
64
|
-
{
|
|
65
|
-
progress: string;
|
|
66
|
-
uploading: boolean;
|
|
67
|
-
uid: string;
|
|
68
|
-
file: File;
|
|
69
|
-
}[]
|
|
70
|
-
>([]);
|
|
71
|
-
const props = withDefaults(
|
|
72
|
-
defineProps<{
|
|
73
|
-
id?: string;
|
|
74
|
-
// folder?: string,
|
|
75
|
-
private?: 1 | 0;
|
|
76
|
-
singleFile?: boolean;
|
|
77
|
-
beforeUpload?: () => Promise<any>;
|
|
78
|
-
dragDropLabel?: string;
|
|
79
|
-
browseLabel?: string;
|
|
80
|
-
}>(),
|
|
81
|
-
{
|
|
82
|
-
private: 0,
|
|
83
|
-
entity: "",
|
|
84
|
-
id: "",
|
|
85
|
-
beforeUpload: async () => { },
|
|
86
|
-
dragDropLabel: "Drag and drop your files here",
|
|
87
|
-
browseLabel: "Browse",
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Drag and drop
|
|
93
|
-
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
function openFileDialog() {
|
|
97
|
-
fileInputEl.value?.click();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function onDragOver(e: DragEvent) {
|
|
101
|
-
if (!draggingOver.value) return;
|
|
102
|
-
// set the position of the circle to the cursor
|
|
103
|
-
const parentEl = dropZoneEl.value?.getBoundingClientRect?.() || {
|
|
104
|
-
left: 0,
|
|
105
|
-
top: 0,
|
|
106
|
-
width: 0,
|
|
107
|
-
height: 0,
|
|
108
|
-
};
|
|
109
|
-
const x = e.clientX - parentEl.left;
|
|
110
|
-
const y = e.clientY - parentEl.top;
|
|
111
|
-
circleLeft.value = `${x}px`;
|
|
112
|
-
circleTop.value = `${y}px`;
|
|
113
|
-
// if the cursor is outside the dropzone, hide the circle
|
|
114
|
-
if (x < 0 || x > parentEl.width || y < 0 || y > parentEl.height) {
|
|
115
|
-
draggingOver.value = false;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function handleFileInput(e: Event) {
|
|
120
|
-
const filesToAdd: FileList = (e.target as any).files;
|
|
121
|
-
addFiles(filesToAdd);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function preventDefaults(e: Event) {
|
|
125
|
-
e.preventDefault();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function hideCircle(e: DragEvent) {
|
|
129
|
-
console.log({ e });
|
|
130
|
-
|
|
131
|
-
draggingOver.value = false;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const events = ["dragenter", "dragover", "dragleave", "drop"];
|
|
135
|
-
|
|
136
|
-
onMounted(() => {
|
|
137
|
-
events.forEach((event) => {
|
|
138
|
-
document.addEventListener(event, preventDefaults);
|
|
139
|
-
});
|
|
140
|
-
document.addEventListener("dragover", onDragOver);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
onUnmounted(() => {
|
|
144
|
-
document.removeEventListener("dragover", onDragOver);
|
|
145
|
-
events.forEach((event) => {
|
|
146
|
-
document.removeEventListener(event, preventDefaults);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* managing files
|
|
152
|
-
*/
|
|
153
|
-
|
|
154
|
-
function addFiles(addedFiles: FileList) {
|
|
155
|
-
if (props.singleFile && files.value.length > 1) return;
|
|
156
|
-
for (let i = 0; i < addedFiles.length; i++) {
|
|
157
|
-
files.value.push({
|
|
158
|
-
file: addedFiles[i],
|
|
159
|
-
uid: Math.random().toString(36).substring(2, 9),
|
|
160
|
-
progress: "",
|
|
161
|
-
uploading: false,
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
uploadFiles();
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*/
|
|
171
|
-
const emit = defineEmits(["complete", "done"]);
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
*
|
|
175
|
-
* server stuff
|
|
176
|
-
*/
|
|
177
|
-
|
|
178
|
-
function uploadFiles() {
|
|
179
|
-
files.value.forEach((item) => {
|
|
180
|
-
item.uploading = true;
|
|
181
|
-
/// TODO upload file
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// function updateProgress(e: ProgressEvent, uid: string) {
|
|
186
|
-
// files.value.find((item) => item.uid === uid).progress = (
|
|
187
|
-
// (e.loaded / e.total)
|
|
188
|
-
// * 100
|
|
189
|
-
// ).toFixed(0);
|
|
190
|
-
// }
|
|
191
|
-
|
|
192
|
-
// function uploadCompleteCallback(file: any, uid: string) {
|
|
193
|
-
// files.value.forEach((item, index) => {
|
|
194
|
-
// if (item.uid === uid) {
|
|
195
|
-
// files.value.splice(index, 1);
|
|
196
|
-
// }
|
|
197
|
-
// });
|
|
198
|
-
// emit('complete', file);
|
|
199
|
-
// if (files.value.length === 0) {
|
|
200
|
-
// fileInputEl.value.value = '';
|
|
201
|
-
// emit('done');
|
|
202
|
-
// }
|
|
203
|
-
// }
|
|
204
|
-
|
|
205
|
-
async function onDrop(e: DragEvent) {
|
|
206
|
-
hideCircle(e);
|
|
207
|
-
preventDefaults(e);
|
|
208
|
-
const filesToAdd = e.dataTransfer?.files;
|
|
209
|
-
if (filesToAdd) {
|
|
210
|
-
addFiles(filesToAdd);
|
|
211
|
-
const file = await bagel.uploadFile(filesToAdd[0]);
|
|
212
|
-
emit("complete", file);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
</script>
|
|
216
|
-
<style>
|
|
217
|
-
/* .uploading-wrap {
|
|
218
|
-
width: 100%;
|
|
219
|
-
} */
|
|
220
|
-
|
|
221
|
-
/* .uploading {
|
|
222
|
-
margin: 0.5rem;
|
|
223
|
-
} */
|
|
224
|
-
|
|
225
|
-
/* .img-label .icon-font {
|
|
226
|
-
font-size: 30px;
|
|
227
|
-
margin-bottom: 10px;
|
|
228
|
-
} */
|
|
229
|
-
|
|
230
|
-
/* .img-label span {
|
|
231
|
-
text-decoration: underline;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.file-input {
|
|
235
|
-
display: none;
|
|
236
|
-
} */
|
|
237
|
-
|
|
238
|
-
.files-wrapper {
|
|
239
|
-
/* flex-direction: column;
|
|
240
|
-
border-radius: 10px; */
|
|
241
|
-
/*overflow: hidden;*/
|
|
242
|
-
/* min-height: 100px;
|
|
243
|
-
font-size: var(--input-font-size); */
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
.drop-zone {
|
|
247
|
-
/* background-color: var(--bgl-bg);
|
|
248
|
-
height: 100%;
|
|
249
|
-
width: 100%;
|
|
250
|
-
flex-grow: 1;
|
|
251
|
-
position: relative;
|
|
252
|
-
overflow: hidden;
|
|
253
|
-
cursor: pointer;
|
|
254
|
-
transition: var(--bgl-transition);
|
|
255
|
-
outline: dashed 1px var(--bgl-black-tint);
|
|
256
|
-
border-radius: 10px;
|
|
257
|
-
padding: 1px;
|
|
258
|
-
display: flex;
|
|
259
|
-
flex-direction: column;
|
|
260
|
-
align-items: center;
|
|
261
|
-
justify-content: center;
|
|
262
|
-
color: var(--input-color); */
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
.drop-zone:hover {
|
|
266
|
-
/* color: var(--bgl-primary);
|
|
267
|
-
outline: dashed 1px var(--bgl-primary-tint); */
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
.drop-circle {
|
|
271
|
-
/* pointer-events: none;
|
|
272
|
-
position: absolute;
|
|
273
|
-
width: 100px;
|
|
274
|
-
height: 100px;
|
|
275
|
-
border-radius: 50%;
|
|
276
|
-
background-color: var(--bgl-primary-tint);
|
|
277
|
-
display: flex;
|
|
278
|
-
top: v-bind(circleTop);
|
|
279
|
-
left: v-bind(circleLeft);
|
|
280
|
-
transform: translate(-50%, -50%) scale(1);
|
|
281
|
-
transform-origin: left top; */
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
/* .drop-circle.active {
|
|
285
|
-
color: red;
|
|
286
|
-
background-color: black;
|
|
287
|
-
transform: translate(-50%, -50%) scale(1);
|
|
288
|
-
transition: transform 0.2s ease-in-out;
|
|
289
|
-
} */
|
|
290
|
-
.load-file-bar {
|
|
291
|
-
/* display: flex;
|
|
292
|
-
align-items: center;
|
|
293
|
-
justify-content: space-between;
|
|
294
|
-
background: var(--bgl-white);
|
|
295
|
-
border-radius: var(--btn-border-radius);
|
|
296
|
-
width: 100%;
|
|
297
|
-
color: var(--input-color);
|
|
298
|
-
height: var(--btn-height);
|
|
299
|
-
padding: 0.5rem;
|
|
300
|
-
box-shadow: 0 1px 2px 0 rgb(0 0 0 / 10%);
|
|
301
|
-
white-space: nowrap; */
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
.load-file-bar p {
|
|
305
|
-
/* width: calc(100% - 40px);
|
|
306
|
-
overflow: hidden;
|
|
307
|
-
text-overflow: ellipsis; */
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
.load-file-bar span {
|
|
311
|
-
/* font-size: 10px; */
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
.pie {
|
|
315
|
-
/* width: 30px;
|
|
316
|
-
height: 30px;
|
|
317
|
-
position: relative;
|
|
318
|
-
display: flex;
|
|
319
|
-
align-items: center;
|
|
320
|
-
justify-content: center; */
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
/* .pie:before {
|
|
324
|
-
content: '';
|
|
325
|
-
position: absolute;
|
|
326
|
-
border-radius: 50%;
|
|
327
|
-
inset: 0;
|
|
328
|
-
background: conic-gradient(var(--bgl-primary) calc(var(--p) * 1%), #0000 0);
|
|
329
|
-
-webkit-mask: radial-gradient(
|
|
330
|
-
farthest-side,
|
|
331
|
-
#0000 calc(99% - var(--b)),
|
|
332
|
-
#000 calc(100% - var(--b))
|
|
333
|
-
);
|
|
334
|
-
mask: radial-gradient(
|
|
335
|
-
farthest-side,
|
|
336
|
-
#0000 calc(99% - var(--b)),
|
|
337
|
-
#000 calc(100% - var(--b))
|
|
338
|
-
);
|
|
339
|
-
} */
|
|
340
|
-
</style>
|
|
341
|
-
<style>
|
|
342
|
-
/* .pop-enter-active {
|
|
343
|
-
transition: scale 0.2s cubic-bezier(0.55, 0, 0.1, 1);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
.pop-leave-active {
|
|
347
|
-
transition: scale 0.2s cubic-bezier(0.55, 0, 0.1, 1);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
.pop-enter-from,
|
|
351
|
-
.pop-leave-to {
|
|
352
|
-
scale: 0;
|
|
353
|
-
} */</style>
|